R 选择输入,然后选择循环绘图
我知道这是一个基本的问题,但我对闪亮真的很陌生 如何将plotlyOutput与SelectInput框中的if循环组合 我的意思是这样的:R 选择输入,然后选择循环绘图,r,shiny,plotly,R,Shiny,Plotly,我知道这是一个基本的问题,但我对闪亮真的很陌生 如何将plotlyOutput与SelectInput框中的if循环组合 我的意思是这样的: vars <- data.frame(location = c("AP LIGUA", "ESCUELA CHALACO"), lat = c(-32.45, -32.183333), lo
vars <- data.frame(location = c("AP LIGUA",
"ESCUELA CHALACO"),
lat = c(-32.45,
-32.183333),
lon = c(-71.216667,
-70.802222)
)
selectInput(inputId = "myLocations", label = "Estación",
choices = vars$location),
if (vars$location=="AP LIGUA") {
plotlyOutput("apligua", height = "100%")
fluidRow(
DT::dataTableOutput("table")
)
}
但是它不起作用。我想您是截断了代码吧?它看起来不像一个闪亮的应用程序。这就是闪亮的应用程序应该是什么样子
vars <- data.frame(location = c("AP LIGUA",
"ESCUELA CHALACO"),
lat = c(-32.45,
-32.183333),
lon = c(-71.216667,
-70.802222)
)
ui <- fluidPage(
selectInput(inputId = "myLocations", label = "Estación",
choices = vars$location),
plotlyOutput("apligua", height = "100%"),
dataTableOutput("table")
)
server <- function(input, output,session) {
output$apligua <- renderPlotly({
if(is.null(input$myLocations)) return() #react to the user's choice if there's one
plot_ly(...)
})
output$table <- renderDataTable({
if(is.null(input$myLocations)) return() #same thing, react to the user's choice
data.table(...)
})
}
shinyApp(ui, server)
我猜:用输入$myLocations==AP LIGUA替换变量$location==AP LIGUA。错误:对象“input”未找到是,被截断。但我想我把我的问题解释得很糟糕。。。我想做的是在选择不同的选项时绘制不同的图形。我在尝试你的答案,但它总是情节,如果AP LIGUA被选中或没有。ifis.nullinput$myLocations==AP LIGUA return我的意思是这样的我不知道你在策划什么。请分享你的绘图代码