【发布时间】:2020-05-10 22:57:20
【问题描述】:
一段时间以来,我一直在使用 flexdashboard 和 plotly graphics 制作 html 文件,直到最近才注意到,当我从本地驱动器打开文件时,我的仪表板中的选项卡没有呈现 plotly 图形。
考虑这个基本的 .rmd 文件:
---
title: "Test Dashboard"
output:
html_document: flexdashboard::flex_dashboard
pdf_document: default
---
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
library(arules)
library(plotly)
library(dplyr)
library(DT)
library(reshape2)
library(stringr)
library(crosstalk)
rf<-data.frame(happiness=c(1,2,3,4,5,6,7,8),
laziness=c(3,4,6,1,2,5,6,1))
```
Association Rules
==================================
Column {.tabset}
----------------------------------
### Table
```{r what2, echo=FALSE, collapse=TRUE, message=FALSE,warning=FALSE}
datatable(rf, filter = 'top', extensions = 'Buttons', options = list(dom = 'Bfrtip', buttons =
c('csv', 'excel','copy', I('colvis')),pageLength = 20, autoWidth = TRUE),rownames = FALSE)
```
### Plot
```{r what, echo=FALSE, collapse=TRUE, message=FALSE, warning=FALSE}
P<-plot_ly(rf,
x=~happiness,
y=~laziness,
color = ~happiness)
P
```
在上面的代码中,我包含了我经常加载的包,如果有人知道这些包之一是罪魁祸首。
当我在 Rstudio 中编织这个 .rmd 以在我的硬盘驱动器上生成一个 .html 文件时,该文件会按预期保存。
导航到文件并打开它(Chrome 和 firefox 已经过测试)导致用户可以很好地看到表格,但绘图的选项卡是空白的。
我当前实际查看绘图的解决方法是将“#plot”附加到浏览器中文件路径的末尾并点击刷新。当我这样做时,情节就出现了,一切都很好。
虽然这对我有用,但它确实降低了其他人使用我的输出文件的乐趣。
任何帮助将不胜感激。
【问题讨论】:
标签: r knitr r-plotly flexdashboard