Coerce data.frame's columns module

coerceUI(id)

coerceServer(input, output, session, data, reactiveValuesSlot = "data")

Arguments

id

Module id. See callModule.

input, output, session

standards shiny server arguments.²

data

A data.frame or a reactive function returning a data.frame or a reactivevalues with a slot containing a data.frame (use reactiveValuesSlot to identify that slot)

reactiveValuesSlot

If data is a reactivevalues, specify the name of the slot containing data.

Value

a reactiveValues with two slots: data original data.frame with modified columns, and names column's names with call to coerce method.

Examples

if (interactive()) { library(esquisse) library(shiny) foo <- data.frame( num_as_char = as.character(1:10), char = sample(letters[1:3], 10, TRUE), fact = factor(sample(LETTERS[1:3], 10, TRUE)), date_as_char = as.character( Sys.Date() + sample(seq(-10, 10), 10, TRUE) ), date_as_num = as.numeric( Sys.Date() + sample(seq(-10, 10), 10, TRUE) ), datetime = Sys.time() + sample(seq(-10, 10) * 1e4, 10, TRUE), stringsAsFactors = FALSE ) ui <- fluidPage( tags$h2("Coerce module"), fluidRow( column( width = 4, coerceUI(id = "example") ), column( width = 8, verbatimTextOutput(outputId = "print_result"), verbatimTextOutput(outputId = "print_names") ) ) ) server <- function(input, output, session) { result <- callModule(module = coerceServer, id = "example", data = reactive({foo})) output$print_result <- renderPrint({ str(result$data) }) output$print_names <- renderPrint({ result$names }) } shinyApp(ui, server) }