Can';t在Rmarkdown报告中生成绘图交互绘图

Can';t在Rmarkdown报告中生成绘图交互绘图,r,knitr,r-markdown,plotly,ggplotly,R,Knitr,R Markdown,Plotly,Ggplotly,我有一个带有plotly绘图的Rmarkdown文档,希望生成一个html文件。当我在Rstudio中单击Knit to HTML时,它会起作用,但在命令行上运行以下命令时,它不会起作用: Rscript -e "require(knitr)" -e "require(markdown)" -e "knit('Untitled.Rmd', out='report.md')" -e "markdownToHTML('report.md', 'report.html')" 在此之后,我有一个rep

我有一个带有plotly绘图的Rmarkdown文档,希望生成一个html文件。当我在Rstudio中单击Knit to HTML时,它会起作用,但在命令行上运行以下命令时,它不会起作用:

Rscript -e "require(knitr)" -e "require(markdown)" -e "knit('Untitled.Rmd', out='report.md')" -e "markdownToHTML('report.md', 'report.html')"
在此之后,我有一个report.html文件,其中包含使用plotly生成的绘图,但它不是交互式的。 有人知道如何使它与命令行交互吗

谢谢

这是代码,顺便说一下:

---
title: "Untitled"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

## R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.

When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

```{r cars}
summary(cars)
```

## Including Plots

You can also embed plots, for example:

```{r pressure_ggplot, echo=FALSE}
library(ggplot2)
library(plotly)
ggplot(pressure,aes(temperature,pressure))+geom_point(size=10,color='red')
```

Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.
```{r pressure_plotly, echo=FALSE}

g<-ggplot(pressure,aes(temperature,pressure))+geom_point(size=10,color='red')
ggplotly(g)
```
```{r}
sessionInfo()
```
---
标题:“无标题”
输出:html\u文档
---
```{r设置,include=FALSE}
knitr::opts_chunk$set(echo=TRUE)
```
##降价
这是一份R降价文件。Markdown是一种用于编写HTML、PDF和MS Word文档的简单格式语法。有关使用R标记的更多详细信息,请参阅。
当您单击**Knit**按钮时,将生成一个文档,其中包括文档中任何嵌入的R代码块的内容和输出。您可以像这样嵌入R代码块:
```{r cars}
摘要(车辆)
```
##包括情节
还可以嵌入打印,例如:
```{r压力图,echo=FALSE}
图书馆(GG2)
图书馆(绘本)
ggplot(压力、aes(温度、压力))+geom_点(尺寸=10,颜色=红色)
```
请注意,“echo=FALSE”参数被添加到代码块中,以防止打印生成绘图的R代码。
```{r pressure_plotly,echo=FALSE}
g试试看:

Rscript-e“库(knitr);库(rmarkdown);rmarkdown::render('untitled.Rmd',output_file='report.html')”

推理:knit似乎默认为markdown输出,markdown不能包含HTML。因此,在转换时,最终会丢失文件(如果从代码块开口中删除
echo=FALSE
,则可以看到这些错误)


rmarkdown::render([…])
以干净的方式呈现为HTML,避免了上述问题。如果您希望指定输出格式,可以使用
output\u format
参数进行指定。

检查,您必须使用
htmltools::tags$..
来嵌入plotly plotsNo,您实际上没有。当我从Rstudio内部编织时,确实会得到一个嵌入的plotly plotly Plott,但当我从命令行执行此操作时就不会了。这就是问题所在。我可能解释得有点不清楚。对不起,您所说的
rmarkdown::render([…])是什么意思
?请提供更多详细信息。谢谢!您想要什么详细信息?哦,对不起,您刚才指的是函数
rmarkdown::render
,我以为您在用方括号做一些花哨的事情。