chart-shiny {toastui} | R Documentation |
Shiny bindings for chart()
Description
Output and render functions for using chart()
within Shiny
applications and interactive Rmd documents.
Usage
chartOutput(outputId, width = "100%", height = "400px")
renderChart(expr, env = parent.frame(), quoted = FALSE)
Arguments
outputId |
Output variable to read from. |
width , height |
Must be a valid CSS unit (like |
expr |
An expression that generates a calendar |
env |
The environment in which to evaluate |
quoted |
Is |
Value
Output element that can be included in UI. Render function to create output in server.
Examples
library(toastui)
library(shiny)
ui <- fluidPage(
fluidRow(
column(
width = 8, offset = 2,
tags$h2("Chart example"),
selectInput("var", "Variable:", names(dimnames(Titanic))),
chartOutput("mychart1"),
chartOutput("mychart2")
)
)
)
server <- function(input, output, session) {
output$mychart1 <- renderChart({
Titanic %>%
as.data.frame() %>%
aggregate(as.formula(paste("Freq", input$var, sep = "~")), data = ., FUN = sum) %>%
chart(caes(x = !!as.symbol(input$var), y = Freq), type = "column")
})
output$mychart2 <- renderChart({
req(input$var != "Survived")
Titanic %>%
as.data.frame() %>%
aggregate(as.formula(paste("Freq ~ Survived", input$var, sep = "+")), data = ., FUN = sum) %>%
chart(caes(x = !!as.symbol(input$var), y = Freq, fill = Survived), type = "column")
})
}
if (interactive())
shinyApp(ui, server)
[Package toastui version 0.3.3 Index]