## Only run examples in interactive R sessions
if (interactive()) {
ui <- lcarsPage(
fluidRow(
column(6,
lcarsRadio("dist1", "Distribution type:",
c("Normal" = "norm",
"Uniform" = "unif",
"Log-normal" = "lnorm",
"Exponential" = "exp"),
inline = TRUE,
label_color = "lilac",
choice_color = "atomic-tangerine"
),
plotOutput("distPlot1")
),
column(6,
lcarsRadioToggle("dist2", "Distribution type:",
c("Normal" = "norm",
"Uniform" = "unif",
"Log-normal" = "lnorm",
"Exponential" = "exp"),
width = "100%"
),
plotOutput("distPlot2")
)
)
)
server <- function(input, output) {
output$distPlot1 <- renderPlot({
dist <- switch(input$dist1,
norm = rnorm,
unif = runif,
lnorm = rlnorm,
exp = rexp,
rnorm)
hist(dist(500))
})
output$distPlot2 <- renderPlot({
dist <- switch(input$dist2,
norm = rnorm,
unif = runif,
lnorm = rlnorm,
exp = rexp,
rnorm)
hist(dist(500))
})
}
shinyApp(ui, server)
}
Run the code above in your browser using DataLab