unexplained error
Closed this issue · 5 comments
Error when attempting to run the example app for teal.modules.general::tm_a_regression
.
library(teal.modules.general)
library(teal.widgets)
data <- teal_data()
data <- within(data, {
library(nestcolor)
CO2 <- CO2
})
datanames <- c("CO2")
datanames(data) <- datanames
app <- init(
data = data,
modules = modules(
tm_a_regression(
label = "Regression",
response = data_extract_spec(
dataname = "CO2",
select = select_spec(
label = "Select variable:",
choices = "uptake",
selected = "uptake",
multiple = FALSE,
fixed = TRUE
)
),
regressor = data_extract_spec(
dataname = "CO2",
select = select_spec(
label = "Select variables:",
choices = variable_choices(data[["CO2"]], c("conc", "Treatment")),
selected = "conc",
multiple = TRUE,
fixed = FALSE
)
),
ggplot2_args = ggplot2_args(
labs = list(subtitle = "Plot generated by Regression Module")
)
)
)
)
runApp(app, launch.browser = TRUE)
[INFO] 2024-02-19 14:17:59.8422 pid:70568 token:[dcda081b] teal Initializing reporter_previewer_module
Warning: Error in super$initialize: Assertion on 'label' failed: Must be of type 'character' (or 'NULL'), not 'list'.
3: runApp
2: print.shiny.appobj
1: <Anonymous>
The app works all right with iris
.
I saw the same error when trying to use the CO2
dataset with another example app.
Error goes away if CO2
is passed through CO2 <- as.data.frame(CO2)
CO2 <- data.frame(CO2)
. This is most likely connected to the labels
attribute of the dataset.
Exactly, attr(dataset, "label", exact = TRUE)
on teal.slice::init_filtered_dataset
would solve the issue
That is, when trying to extrapolate the label on the S3 method arguments an exact match would solve this.
A (?better?) alternative would be to ignore the default value if attr(dataset, "label")
is not a string (with or without the exact = TRUE
).
edit: although this would a lot of complexity to the argument code
I think ensuring exact matching is the better way to go.
I guess this should be moved to teal.slice
then. Would you do the honors?