这是我的问题;我无法正确设置 conditionalPanel 来与 selectInput 一起使用。我需要的是在选择“AP LIGUA”时绘制apligua,在选择“LAS CRUZADAS”时绘制lascruzadas。但 Shiny 正在绘制这两个图表。
请帮忙...
在服务器中:
vars <- data.frame(location = c("AP LIGUA",
"LAS CRUZADAS"),
lat = c(-32.45,
-32.183333),
lon = c(-71.216667,
-70.802222)
)
output$apligua <- renderPlotly({
theme_set(theme_bw())
ggplot(aes(x = datos2$horafecha, y = datos2$altura2), data = datos2) +
geom_line() +
geom_point() +
geom_smooth(method = "auto", colour='blue', span=0.2) +
ylab("Altura (m) ") +
xlab("Meses")
})
output$lascruzadas <- renderPlotly({
theme_set(theme_bw())
ggplot(aes(x = datos$horafecha, y = datos$altura2), data = datos) +
geom_line() +
geom_point() +
geom_smooth(method = "auto", colour='blue', span=0.2) +
ylab("Altura (m) ") +
xlab("Meses")
})
在用户界面中
selectInput(inputId = "myLocations", label = "Estación",
choices = vars$location),
conditionalPanel("input.myLocations" == "LAS CRUZADAS",
plotlyOutput("lascruzadas", height = "100%")
),
conditionalPanel("input.myLocations" == "AP LIGUA",
plotlyOutput("apligua", height ="100%")
)
(已编辑错误)
最佳答案
你的条件应该是Javascript代码的一个字符串。所以,类似于:
"input.myLocations == 'LAS CRUZADAS'"
注意单引号。
关于r - 条件面板和选择输入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41961926/