这是我的代码:
ui <- fluidPage(
radioButtons("dist", "Distribution type:",
c("Sepal.Length" = "Length",
"Sepal.Width" = "Width",
"Petal.Length" = "Length")),
plotOutput("distPlot")
)
server <- function(input, output) {
output$distPlot <- renderPlot({
dist <- switch(input$dist,
"Length" = plot(iris$Sepal.Length),
"Width" = plot(iris$Sepal.Width),
"Length" = plot(iris$Sepal.Length))
plot(dist)
})
}
shinyApp(ui, server)
}
我究竟做错了什么?
另外,我希望每个按钮都有一个 par(mfrow=c(1,2))
图 . 我怎样才能做到这一点?
有帮助吗?
谢谢
1 回答
您不需要绘制已分配的函数,因为
switch
it0s已经这样做了 .编辑:关于使用par
(mfrow=c(1,2))
,尽管我对其他选择的评论,这是我提出的替代方案: