Description Usage Arguments Details Value Examples
This module gives a way to manipulate dataframes by changing column names and column classes. Also, datasets can be filtered based on user inputs.
1 2 3 4 5 | variableView(input, output, session, dataset, dataName = "dat")
variableViewUI(id)
selectedVar(id)
|
input, output, session |
Standard module parameters. |
dataset |
A |
dataName |
A |
id |
The id of the module. |
selectedVar
is an optional ui element which will show a summary of the
variable selected in
variableViewUI
.
A list with the following entries
code
a reactive string representing the code to transform the dataset.
get_state()
A function to export the state of the widget into an
R object
get_state(state)
A function to restore a saved state. The dataset
provided in dataset
must be the same as when get_state()
was called
in order to ensure a proper restore
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 | ## Not run:
library(DT)
data("tips", package = "reshape2")
data("diamonds", package = "ggplot2")
shinyApp(
fluidPage(
column(6, selectInput("dataset", "choose dataset",
choices = c("mtcars", "tips", "diamonds")),
variableViewUI("vv"), actionButton("save", "save"),
actionButton("load", "load")),
column(6, codeOutput("code"), selectedVar("vv"), DTOutput("filtered"))
),
function(input, output, session){
dataset <- reactive({get(input$dataset)})
varView <- callModule(variableView, "vv", dataset)
state <- NULL
observeEvent(input$save, {
state <<- isolate(varView$get_state())
})
observeEvent(input$load, {
varView$set_state(state)
})
output$code <- renderCode({ varView$code() })
output$filtered <- renderDT({
dat <- isolate(dataset())
eval(parse(text = varView$code()))
dat
})
},
options = list(launch.browser = TRUE)
)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.