【问题标题】:ggplot plot from esquisse package not rendering in flexdashboard来自 esquisse 包的 ggplot 图未在 flexdashboard 中呈现
【发布时间】:2021-04-27 14:21:10
【问题描述】:

当我尝试将出色的 esquisse shinymodule 包含到 flexdashboard 中时,绘图不会呈现。

下面的示例尝试从帮助中翻译 Shiny 示例以在 flexdashboard 中使用,但尽管它显示和读取数据(它显示列名并且在选择“汽车”数据时这些更改),但它没有更新图表菜单也不会渲染图表。

使用 esquisse Shiny 模块时如何渲染绘图?

---
title: "Quick demo for Data"
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
runtime: shiny
---


   
Test
=====================================     
```{r}


library(esquisse)
# shiny inputs defined here
radioButtons(
    inputId = "data", 
    label = "Data to use:", 
    choices = c("iris", "mtcars"))

checkboxGroupInput(
    inputId = "aes", 
    label = "Aesthetics to use:", 
    choices = c(
      "fill", "color", "size", "shape", 
      "weight", "group", "facet", "facet_row", "facet_col"
    ),
    selected = c("fill", "color", "size", "facet"))

  esquisse_ui(
    id = "esquisse", 
    header = FALSE, # dont display gadget title
    container = esquisseContainer(height = "700px"))
  
  
  data_rv <- reactiveValues(data = iris, name = "iris")
  
  observeEvent(input$data, {
    if (input$data == "iris") {
      data_rv$data <- iris
      data_rv$name <- "iris"
    } else {
      data_rv$data <- mtcars
      data_rv$name <- "mtcars"
    }
  })
  
  esquisse_server(
    id = "esquisse", 
    data_rv = data_rv, 
    default_aes = reactive(input$aes)
  )
 
  
```

【问题讨论】:

  • 将第一个标签放在第一个框中时,某些内容未呈现。从未听说过 esquisse 包,但它非常有趣。我可以建议先使用 1 个数据集,直到您发现图表未显示。我也会研究esquisse。谢谢
  • 我的第一个想法是反应性不起作用,但考虑到在选择另一个数据集时列名会发生变化,它在一定程度上起作用。另外,如果将上述reprex中的header改为TRUE,就可以在环境中选择一个数据集。
  • 输出窗口下方的日志显示&lt;ReactiveValues&gt; Values: code_filters, code_plot, data Readonly: FALSE ,通常当您添加变量时,它会建议适用的绘图(自动图标所在的位置)。
  • @Lod 你找到解决方案了吗?

标签: r ggplot2 flexdashboard shinymodules


【解决方案1】:

我已将esquisse_ui() 函数放入renderUI() 函数中,它工作正常。试试看吧。

完整示例:

```{r}
esqSData <- reactiveValues(data = mydata, name = "My Data")

esquisse_server(
  id = "esquisse",
  data_rv = esqSData,
  import_from = c("env", "file", "copypaste", "googlesheets") )

renderUI(
  esquisse_ui(
    id = "esquisse",
    header = TRUE,
    container = esquisseContainer(),
    controls = c("labs", "parameters", "appearance", "filters", "code"),
    insert_code = FALSE
    )
)
```

【讨论】:

    猜你喜欢
    • 2018-05-01
    • 2018-09-20
    • 2019-11-25
    • 2021-05-01
    • 2020-10-09
    • 1970-01-01
    • 2013-12-22
    • 1970-01-01
    • 2019-01-06
    相关资源
    最近更新 更多