사용자가 플롯 할 인스턴스 (요인 수준)를 선택할 수 있도록 R로 데이터를 플롯하려고합니다. 나는 plotly을 사용하여 이것을 수행하고 Shiny Server을 사용하여 호스트하고 싶습니다.플롯 및 샤이니 서버를 사용하여 중복 된 범례 항목
문제는 선택한 항목을 업데이트 한 후 모든 범례 항목이 두 번 반복된다는 것입니다. 즉, 처음 올바르게 렌더링 할 때 다른 변수를 클릭하여 문제가 나타납니다. 여기
는 그림 :![enter image description here](https://i.stack.imgur.com/SsrW5.png)
이상한 부분 (R 스튜디오 내부, 예를 들어, 또는 runApp()
를 사용하여) 로컬로 실행 또는 shinyapps.io 사용하지만 반짝 서버를 사용하는 경우 때이 문제가없는 것입니다 .R
이 문제를 해결하고 중복 항목을 피할 방법이 있습니까?
재현 예 :
library(plotly)
ui <- fluidPage(
fluidRow(
column(2,
checkboxGroupInput("species",
label = "Species",
choices = unique(iris$Species))),
column(10,
plotlyOutput('irisPlotly'))
)
)
server <- function(input, output) {
# Filter only selected species
selectedData <- reactive({
iris[iris$Species %in% input$species, ]
})
# Render plotly plot
output$irisPlotly <- renderPlotly({
plot_ly(selectedData(),
x = ~Sepal.Length,
y =~Sepal.Width,
color = ~Species) %>%
layout(showlegend = TRUE)
})
}
shinyApp(ui = ui, server = server)
출력 sessionInfo()
의 :
R version 3.3.2 (2016-10-31)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Arch Linux
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] plotly_4.5.6.9000 ggplot2_2.2.1.9000 shiny_1.0.0
loaded via a namespace (and not attached):
[1] Rcpp_0.12.9 magrittr_1.5 munsell_0.4.3 viridisLite_0.1.3
[5] colorspace_1.3-2 xtable_1.8-2 R6_2.2.0 httr_1.2.1
[9] plyr_1.8.4 dplyr_0.5.0 tools_3.3.2 grid_3.3.2
[13] gtable_0.2.0 DBI_0.5-1 crosstalk_1.0.0 htmltools_0.3.5
[17] yaml_2.1.14 lazyeval_0.2.0 digest_0.6.12 assertthat_0.1
[21] tibble_1.2 tidyr_0.6.1 purrr_0.2.2 base64enc_0.1-3
[25] htmlwidgets_0.8 mime_0.5 scales_0.4.1 jsonlite_1.3
[29] httpuv_1.3.3
내 Mac 랩톱에서 로컬로 코드를 테스트했는데 범례 문제를 재현 할 수 없습니다. Chrome, Firefox 및 Safari에서 테스트되었습니다. 내 sessionInfo : R 버전 3.3.3 (2017-03-06), 플랫폼 : x86_64-apple-darwin13.4.0 (64 비트), 아래 실행 : OS X El Capitan 10.11.6, plotly_4.5.6, ggplot2_2.2.1, shiny_1.0.0. – bdemarest
@bdemarest Shiny Server를 사용할 때만 문제가 로컬에서 ('runApp()'를 사용하여) 실행할 때 존재하지 않는다는 설명이 추가되었습니다. –
'sessionInfo()'데이터도 포함해야합니다. –