mirror of
https://github.com/rstudio/shiny.git
synced 2026-04-07 03:00:20 -04:00
27 lines
557 B
R
27 lines
557 B
R
library(shiny)
|
|
library(datasets)
|
|
|
|
shinyServer(function(input, output) {
|
|
|
|
formulaText <- reactive(function() {
|
|
paste("mpg ~", input$variable)
|
|
})
|
|
|
|
mpgData <- reactive(function() {
|
|
data <- mtcars
|
|
data$cyl <- as.factor(data$cyl)
|
|
data$am <- factor(data$am, labels = c("Automatic", "Manual"))
|
|
data
|
|
})
|
|
|
|
output$caption <- reactive(function() {
|
|
formulaText()
|
|
})
|
|
|
|
output$plot <- reactivePlot(function() {
|
|
boxplot(as.formula(formulaText()),
|
|
data = mpgData(),
|
|
outline = input$outliers)
|
|
})
|
|
})
|