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

[Bug]: tm_a_pca doesn't work with delayed data extract specs #715

Open
3 tasks done
averissimo opened this issue Apr 8, 2024 · 0 comments
Open
3 tasks done

[Bug]: tm_a_pca doesn't work with delayed data extract specs #715

averissimo opened this issue Apr 8, 2024 · 0 comments
Labels
bug Something isn't working core

Comments

@averissimo
Copy link
Contributor

What happened?

Problem

Example of tm_a_pca using a character name for the dataset to extract the data does not behave the same and produces an error.

When inspecting the code, response[[i]] variable processing assumes that it's not a delayed_data object.

response[[i]]$select$multiple <- FALSE
response[[i]]$select$always_selected <- NULL
response[[i]]$select$selected <- NULL
all_cols <- teal.data::col_labels(isolate(data())[[response[[i]]$dataname]])
ignore_cols <- unlist(teal.data::join_keys(isolate(data()))[[response[[i]]$dataname]])
color_cols <- all_cols[!names(all_cols) %in% ignore_cols]
response[[i]]$select$choices <- choices_labeled(names(color_cols), color_cols)

How to reproduce:

library(teal.module.general)

data <- within(teal_data(), {
  require(nestcolor)
  USArrests <- USArrests
})
datanames(data) <- "USArrests"

## Delayed data (with error)
teal::init(
  data = data,
  modules = teal.module.general::tm_a_pca(
    dat = teal.transform::data_extract_spec(
      dataname = "USArrests",
      select = select_spec(
        choices = teal.transform::variable_choices(
          data = "USArrests",
          c("Murder", "Assault", "UrbanPop", "Rape")
        ),
        selected = c("Murder", "Assault"),
        multiple = TRUE
      )
    )
  )
) |> shiny::runApp()

image

Expected behavior

Same result using example for module (that uses variable_choices with data itself instead of character)

# Non-delayed data (without error)
teal::init(
  data = data,
  modules = tm_a_pca(
    dat = data_extract_spec(
      dataname = "USArrests",
      select = select_spec(
        choices = variable_choices(
          data = data[["USArrests"]],
          c("Murder", "Assault", "UrbanPop", "Rape")
        ),
        selected = c("Murder", "Assault"),
        multiple = TRUE
      )
    )
  )
) |> shiny::runApp()

sessionInfo()

No response

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct.

Contribution Guidelines

  • I agree to follow this project's Contribution Guidelines.

Security Policy

  • I agree to follow this project's Security Policy.
@averissimo averissimo added bug Something isn't working core labels Apr 8, 2024
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

1 participant