【发布时间】:2018-05-30 14:16:24
【问题描述】:
在 Shinyapp 中,我有一个 selectInput,我可以在其中选择一些值。然后我想绘制 y~selected 值。 我可以绘制像 plot(mtcars$mpg~mtcars$wt) 这样定义的图,但我不想绘制 情节(mtcars$mpg~选定值)
谁能帮帮我。我的代码是这样的:
library(shiny)
ui <- fluidPage(
titlePanel("MyPLot"),
sidebarLayout(
sidebarPanel(
selectInput("variable", "Variable:", c("Cylinders" = "cyl", "Transmission" = "am", "Gears" = "gear"))
),
mainPanel(
plotOutput("distPlot"),
plotOutput("secPlot")
)
)
)
server <- function(input, output) {
output$distPlot <- renderPlot({plot(mtcars$mpg~mtcars$wt) })
output$secPlot <- renderPlot({ plot(mtcars$mpg~input$variable) })
}
shinyApp(ui = ui, server = server)
【问题讨论】: