在Rstudio之外的rmarkdown笔记本(html笔记本)中使用plotly

时间:2018-05-01 14:13:58

标签: r rstudio r-markdown r-plotly ggplotly

是否可以将html_notebook aka r notebook格式与plotly一起使用?

当我使用下面显示的rmarkdown文件(名为temp.Rmd)时,我可以knit to HTML并且一切正常 - 也就是说,我可以查看正确的temp.html文件。但是,当我使用Preview Notebook中的RStudio按钮打开预览窗格或查看temp.nb.html文件时,我错过了plotly输出。

temp.Rmd

---
title: "R Notebook"
output:
  html_notebook: default
  html_document:
    df_print: paged
---

Some text here.

```{r message = FALSE, warning = FALSE}
library(ggplot2)
library(plotly)

p <- ggplot(mtcars, aes(x = cyl, y = mpg)) + geom_point()
ggplotly(p, width = 500, height = 500)

mtcars
```

More text here.

会话信息

Session info ---------------------------------------------------------------
 setting  value                       
 version  R version 3.5.0 (2018-04-23)
 system   x86_64, mingw32             
 ui       RStudio (1.2.593)           
 language (EN)                        
 collate  English_United States.1252  
 tz       America/New_York            
 date     2018-05-01      

 ggplot2     * 2.2.1.9000 2018-04-27 Github (tidyverse/ggplot2@1d537ce)
 plotly      * 4.7.1.9000 2018-04-27 Github (ropensci/plotly@38f447f)  

0 个答案:

没有答案