Description Format Input Output Super class Methods See Also Examples
Shiny TidyModule
to select variables from a data set. Includes exporting functionality (to HTML). Interface uses bs4Dash.
R6 class
dataset
A data sets. Can be tibble, data frame, etc.
options
The options for the module of type reactiveValues
with values
datasetname
The default dataset name that will appear in the header. Default: ""
idvar
ID field that is common across all datasets in input:datalist
. Default USUBJID
filtered_indices
The output data set indices after filtering, selecting and reordering columns.
filtered_data
The output data set after filtering, selecting and reordering columns.
filtered_columns
The names of the columns that have been selected.
search_columns
The searches applied to the data table.
tidymodules::TidyModule
-> VariableSelection
new()
VariableSelection$new(...)
ui()
VariableSelection$ui()
server()
VariableSelection$server( input, output, session, dataset = NULL, options = NULL )
clone()
The objects of this class are cloneable with this method.
VariableSelection$clone(deep = FALSE)
deep
Whether to make a deep clone.
Other tidymodules:
Filter
,
SubgroupManager
,
Subgroup
,
SubpopulationManager
,
Subpopulation
,
TTEMapping
,
TTE
,
TableListing
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | ## Not run:
library(tidymodules)
library(bs4Dash)
library(subpat)
varSelMod <- VariableSelection$new()
ui <- tagList(
shinyjs::useShinyjs(),
bs4DashPage(
sidebar = bs4DashSidebar(disable = TRUE),
body = bs4DashBody(
fileInput("file1", "Choose SAS File",
multiple = FALSE,
accept = c(".sas7bdat")),
conditionalPanel(condition = 'output.file_uploaded',
varSelMod$ui(),
verbatimTextOutput('tableIndices'),
verbatimTextOutput('filteredTable'),
verbatimTextOutput('searchColumns'))
)
)
)
# Define server logic
server <- function(input, output) {
opts <- reactiveValues(
datasetname = NULL,
idvar = "USUBJID"
)
varSelMod$callModule()
output$file_uploaded <- reactive({
return(!is.null(input$file1))
})
outputOptions(output, 'file_uploaded', suspendWhenHidden=FALSE)
observe({
req(input$file1)
dat <- haven::read_sas(input$file1$datapath)
opts$datasetname <- input$file1$name
# Pass the uploaded data into the module
reactive(dat) %>1% varSelMod
# Pass the options into the module
opts %>2% varSelMod
})
# Show the output indices from the module
output$tableIndices <- renderPrint({
print(varSelMod$getOutput("filtered_indices")())
})
# Show the filtered data from the table
output$filteredTable <- renderPrint({
print(varSelMod$getOutput("filtered_data")())
})
# Show the strings entered in the search columns
output$searchColumns <- renderPrint({
print(varSelMod$getOutput("search_columns")())
})
}
# Run the application
shinyApp(ui = ui, server = server)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.