insightsengineering / insightsengineering/teal.modules.general

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

Open
#715 0 comments 0 reactions 0 assignees View on GitHub
bug core
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()
```

![image](https://github.com/insightsengineering/teal.modules.general/assets/211358/52f59aea-403c-49fb-a378-956410b4c0b3)

#### 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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.