首页 > 解决方案 > 交互式 ggPredict whitin R Shiny FlexDashboard

问题描述

我正在使用 Flexdashboard 创建一个 R Shiny App;对于我正在使用ggiraphExtra包中的 ggPredict() 的图表

这是我需要使用 mtcars 数据集进行线性回归的以下图块:

### Graph2
```{r}

renderPlot({
  Reg_LM <- lm(mpg ~ disp + hp, data = mtcars) 
  ggPredict(Reg_LM, interactive = F)
})

```

当我使用interactive = F运行我的 ggPredict 时,我的情节运行完美!

但是当我添加interactive = T(以获得更好的体验)时,我的情节就消失了(不返回任何错误消息)

我的猜测是 R Shiny 不支持来自 ggPredict 的interactive = T。可能是这样吗?或者 FlexDashboard 需要另一种方式来处理这个问题?

谢谢!

标签: rshinyflexdashboardggiraph

解决方案


谢谢@RyanMorton

这是完美运行的代码:

### Graph2
```{r}

output$plot5 <- renderggiraph({

  ggiraph(code = print(ggPredict(lm(mpg ~ disp + hp + drat, data = mtcars),
                                 colorAsFactor = T,
                                 point = F)))
})

ggiraphOutput("plot5")


```

推荐阅读