Creates a named list of data_extract_srv
output
data_extract_multiple_srv.Rd
data_extract_multiple_srv
loops over the list of data_extract
given and
runs data_extract_srv
for each one returning a list of reactive objects.
This is suitable as input for data_merge_srv()
.
Arguments
- data_extract
(named
list
ofdata_extract_spec
objects) the listdata_extract_spec
objects. The names of the elements in the list need to correspond to theids
passed todata_extract_ui
. See example for details.- datasets
(
FilteredData
)
object containing data, see teal.slice::FilteredData for more.
Value
reactive named list containing outputs from data_extract_srv()
. Output list
names are the same as data_extract
input argument.
Examples
library(shiny)
ADSL <- data.frame(
STUDYID = "A",
USUBJID = LETTERS[1:10],
SEX = rep(c("F", "M"), 5),
AGE = rpois(10, 30),
BMRKR1 = rlnorm(10)
)
data <- teal.data::teal_data(teal.data::dataset("ADSL", ADSL))
datasets <- teal.slice:::filtered_data_new(data)
teal.slice:::filtered_data_set(data, datasets)
xvar_extract <- data_extract_spec(
dataname = "ADSL",
filter = filter_spec(vars = "SEX", choices = c("F", "M"), selected = "F"),
select = select_spec(
label = "Select variable:",
choices = variable_choices(ADSL, c("AGE", "BMRKR1")),
selected = "AGE",
multiple = TRUE,
fixed = FALSE
)
)
yvar_extract <- data_extract_spec(
dataname = "ADSL",
select = select_spec(
label = "Select variable:",
choices = variable_choices(ADSL, c("AGE", "BMRKR1")),
selected = "BMRKR1",
multiple = TRUE,
fixed = FALSE
)
)
app <- shinyApp(
ui = fluidPage(
teal.widgets::standard_layout(
output = verbatimTextOutput("out1"),
encoding = tagList(
data_extract_ui(id = "xvar", label = "Select x-var", xvar_extract),
data_extract_ui(id = "yvar", label = "Select y-var", yvar_extract),
)
)
),
server = function(input, output, session) {
list_of_reactive_inputs <- data_extract_multiple_srv(
# names of the list corresponding to data_extract_ui ids
list(xvar = xvar_extract, yvar = yvar_extract),
datasets
)
output$out1 <- renderPrint({
lapply(list_of_reactive_inputs(), function(x) x())
})
}
)
if (FALSE) {
runApp(app)
}