insightsengineering / insightsengineering/teal.modules.general
[Bug]: `tm_a_pca` doesn't work with delayed data extract specs
- Dominant language
- R
- Stars
- 16
- Forks
- 23
- PR merge metrics
- No merged PRs in 30d
Description
### 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.
https://github.com/insightsengineering/teal.modules.general/blob/99d7f0256a10be0c84afbf160bf1a093f63ae44f/R/tm_a_pca.R#L304-L310
#### How to reproduce:
```r
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()
```

#### Expected behavior
Same result using example for module (that uses `variable_choices` with data itself instead of character)
```r
# 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
- [X] I agree to follow this project's Code of Conduct.
### Contribution Guidelines
- [X] I agree to follow this project's Contribution Guidelines.
### Security Policy
- [X] I agree to follow this project's Security Policy.
Contributor guide
Assessment
This issue has not been assessed yet.