【发布时间】:2017-05-05 19:51:06
【问题描述】:
我正在尝试创建我的第一个 Shiny 应用程序,我基本上是在尝试让该应用程序绘制两个简单的直方图,但是通过输入按钮让用户选择是否要并排查看两个直方图(水平)或一个低于另一个(垂直)。
我尝试编写下面的代码更多是为了向您解释我的思维过程,而不是真正希望它会起作用。
感谢任何帮助,谢谢!
library(shiny)
ui <- fluidPage(
radioButtons('layout', 'Layout:', choices=c('Vertically', 'Horizontally'), inline=TRUE),
sliderInput(inputId = "num",
label = "Choose a number",
value = 25, min = 1, max = 100),
plotOutput("hist1"),
plotOutput("hist2"))
server <- function(input,output) {
if (input$layout == "Horizontally") {
output$hist1<-fluidRow(
column(3,plotOutput(hist(rnorm(input$num)))))
output$hist2<-column(3,plotOutput(hist(rnorm(input$num))))
}
else if (input$layout == "Vertically") {
output$hist1<-fluidRow(
column(3,plotOutput(hist(rnorm(input$num)))))
output$hist2<-fluidRow(
column(3,plotOutput(hist(rnorm(input$num)))))
}
}
shinyApp(ui=ui, server=server)
【问题讨论】:
标签: shiny shinydashboard