Description Usage Arguments Value Examples
Coerce data.frame's columns module
1 2 3 | coerceUI(id)
coerceServer(input, output, session, data, reactiveValuesSlot = "data")
|
id |
Module id. See |
input, output, session |
standards |
data |
A |
reactiveValuesSlot |
If |
a reactiveValues
with two slots: data
original data.frame
with modified columns, and names
column's names with call to coerce method.
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 | 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)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.