相关疑难解决方法(0)

使用选择框通过 R 中的串扰在 R 绘图中选择默认值,使用静态 html 不闪亮

在 Rmarkdown html 文档中,如何为 crosstalk::filter_select 下拉列表选择一个默认值,该下拉列表将与绘图一起使用?例如,在下面的示例中,在编织 RMD 时仅选择组“a”。

我知道对于下面的 reprex 示例,使用 plotly 按钮会更容易,但是当有超过 4-5 个左右的选择时,plotly 下拉菜单/按钮占用太多空间/非常难看。也希望避免运行闪亮的服务器,这个想法是为了速度目的让所有东西都在客户端运行。

串扰中有一个 PR 为 filter_select 函数添加了“默认选择”参数,但该版本不适用于 plotly ( https://github.com/rstudio/crosstalk/pull/70 )。我想最简单的方法是在文档中添加 javascript 来操作串扰对象,但是一些实验还没有进行到很远。

Reprex rmd:

---
output:
  html_document
---

```{r echo=FALSE, message=FALSE, warning=FALSE}


library(plotly)
# example data 
dat <- tibble::tribble(~filterBy, ~x, ~y,
                        "a", 1, 1,
                        "b", 2, 1,
                        "a", 1, 2,
                        "b", 2, 2,
                        "a", 1, 3,
                        "b", 2, 3,
                        "a", 1, 2,
                        "b", 2, 3,
                        "c", 3, 1,
                        "c", 3, 2,
                        "c", 3, 3
                        ) …
Run Code Online (Sandbox Code Playgroud)

javascript r shiny flexdashboard r-plotly

5
推荐指数
1
解决办法
942
查看次数

标签 统计

flexdashboard ×1

javascript ×1

r ×1

r-plotly ×1

shiny ×1