Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tm_t_crosstable fails if data has no joining keys #649

Open
chlebowa opened this issue Feb 20, 2024 · 2 comments
Open

tm_t_crosstable fails if data has no joining keys #649

chlebowa opened this issue Feb 20, 2024 · 2 comments
Labels
bug Something isn't working core

Comments

@chlebowa
Copy link
Contributor

Run an app with normal data and select the same variable for both row values and column values.

normal data
library(teal)

data <- teal_data()
data <- within(data, {
  CO2 <- CO2
})
datanames(data) <- "CO2"
app
library(teal.modules.general)
library(teal.widgets)

app <- init(
  data = data,
  modules = modules(
    tm_t_crosstable(
      label = "Cross Table",
      x = data_extract_spec(
        dataname = "CO2",
        select = select_spec(
          label = "Select variable:",
          choices = variable_choices(data[["CO2"]], c("Plant", "Type", "Treatment")),
          selected = "Plant",
          multiple = TRUE,
          ordered = TRUE,
          fixed = FALSE
        )
      ),
      y = data_extract_spec(
        dataname = "CO2",
        select = select_spec(
          label = "Select variable:",
          choices = variable_choices(data[["CO2"]], c("Plant", "Type", "Treatment")),
          selected = "Treatment",
          multiple = FALSE,
          fixed = FALSE
        )
      ),
      basic_table_args = basic_table_args(
        subtitles = "Table generated by Crosstable Module"
      )
    )
  )
)
runApp(app, launch.browser = TRUE)
error

image

Now run the app with data that has a primary key added:

data <- teal_data()
data <- within(data, {
  CO2 <- CO2
  CO2[["primary_key"]] <- seq_len(nrow(CO2))
})
datanames(data) <- "CO2"
join_keys(data) <- join_keys(join_key("CO2", "CO2", "primary_key"))

The app now works as intended.

@chlebowa chlebowa added bug Something isn't working core labels Feb 20, 2024
@kumamiao
Copy link

kumamiao commented Jun 6, 2024

also check if other modules have this error

@chlebowa
Copy link
Contributor Author

chlebowa commented Jun 7, 2024

also check if other modules have this error

Already have. Note that all modules have general and CDISC data examples now, I logged all erors like this during #651

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working core
Projects
None yet
Development

No branches or pull requests

2 participants