到目前爲止所有的幫助,但不得不自己教R/Shiny,沒有人在辦公室幫忙,我不幸再次卡住!R的Checkboxgroupinput Plotly閃亮
我想在Shiny中做checkboxgroups。我讀了不少,例如this,this,this,this和this已經幫助,但我現在卡住了。
所以把我的數據 「ConversionsCompletions」 現在看起來是這樣的:
date | goal1completions | goal
--------------------------------------------
01012016 | 4 | goal1
01012016 | 10 | goal2
01012016 | 8 | goal3
01012016 | 13 | goal4
02012016 | 6 | goal1
02012016 | 7 | goal2
.....
UI:
checkboxGroupInput("checkGroup", label = h3("Goal"),
choices = c("Goal 1" = "goal1",
"Goal 2" = "goal2",
"Goal 3" = "goal3",
"Goal 4" = "goal4",
"Goal 5" = "goal5",
"Goal 6" = "goal6",
"Goal 7" = "goal7"),
selected = "Goal 1")
plotlyOutput("Conversionrate1")
服務器:
filteredData <- reactive({
filter(ConversionsCompletions[ConversionsCompletions$goal %in% input$checkGroup,])
})
output$Conversionrate1 <- renderPlotly({
plot_ly(filteredData(), x = ConversionsCompletions$date, y = ConversionsCompletions$goal1Completions, mode = "lines + markers", hoverinfo = y)
})
有一種圖形,但它不當我切換盒子或一次顯示多行時不會改變。我知道通常你需要爲plotly圖表添加「add_trace」代碼,所以我不確定在這種情況下如何做到這一點,有時有一行,有時是多行。
任何幫助讚賞!
你想爲每個「目標」分開一行嗎? –
理想情況下......這可能嗎? – RSesom
我正在努力:) –