[Note: although I'm posting under the 'shiny' heading, I'd rather keep this server-free if possible]
I'm struggling to have an interactive selection that updates both a plotly object and a datatable. It works fine with one point, but when I set options(persistent = TRUE)
to enable multiple selections the selected rows don't match up. Any idea?
---
title: testing interaction
output: html_document
---
```{r, echo=FALSE,warning=FALSE,message=FALSE}
library(crosstalk)
library(plotly)
library(DT)
d <- data.frame(x=1:10,y=1:10,f=gl(2,5,labels = letters[1:2]))
sd <- SharedData$new(d)
# options(persistent = TRUE)
p <- ggplot(sd, aes(x, y)) +
geom_text(aes(label=f)) +
theme_void()
bscols(
ggplotly(p) %>%
highlight(color = "red",on = "plotly_click"),
datatable(sd, style="bootstrap", class="compact", width="100%",
options=list(deferRender=FALSE, dom='t')))
```
Incorrect output with options(persistent = TRUE)
,
sessionInfo()
R version 3.4.3 Patched (2017-12-15 r73919)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Sierra 10.12.6
Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib
locale:
[1] en_NZ.UTF-8/en_NZ.UTF-8/en_NZ.UTF-8/C/en_NZ.UTF-8/en_NZ.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] ggplot2_2.2.1.9000 tibble_1.4.2 tidyr_0.7.2 purrr_0.2.4
[5] plyr_1.8.4 yaml_2.1.16 crosstalk_1.0.1
loaded via a namespace (and not attached):
[1] Rcpp_0.12.15 compiler_3.4.3 pillar_1.1.0 git2r_0.20.0 tools_3.4.3
[6] digest_0.6.15 evaluate_0.10.1 memoise_1.1.0 gtable_0.2.0 rlang_0.1.6.9003
[11] shiny_1.0.5 curl_3.1 withr_2.1.1.9000 httr_1.3.1 stringr_1.2.0
[16] knitr_1.18 htmlwidgets_1.0 devtools_1.13.4 rprojroot_1.3-1 grid_3.4.3
[21] DT_0.4 glue_1.2.0 R6_2.2.2.9000 rmarkdown_1.8 magrittr_1.5
[26] backports_1.1.2 scales_0.5.0.9000 htmltools_0.3.6 rsconnect_0.8.5 mime_0.5
[31] xtable_1.8-2 colorspace_1.3-2 httpuv_1.3.5 labeling_0.3 stringi_1.1.6
[36] lazyeval_0.2.1 munsell_0.4.3