variableView: SPSS like variable view

Description Usage Arguments Details Value Examples

View source: R/variableView.R

Description

This module gives a way to manipulate dataframes by changing column names and column classes. Also, datasets can be filtered based on user inputs.

Usage

1
2
3
4
5
variableView(input, output, session, dataset, dataName = "dat")

variableViewUI(id)

selectedVar(id)

Arguments

input, output, session

Standard module parameters.

dataset

A reactive table (for example a data.frame)

dataName

A character of length one giving the name of the dataset.

id

The id of the module.

Details

selectedVar is an optional ui element which will show a summary of the variable selected in variableViewUI.

Value

A list with the following entries

Examples

 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)

statistikat/codeModules documentation built on Feb. 17, 2021, 11:42 a.m.