我曾尝试从命令行运行Shiny,但无法运行。我已经创建了一个闪亮的演示文件,这是我尝试使用的命令,我得到的错误如下:
---
title: "Test"
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: fill
---
```{r setup, include=FALSE}
库(Flexdashboard)
库(Tidyverse)
```{r plot1}
ggplot(mpg,mapping = aes(x = displ,y= hwy)) +
Geom_point(映射=aes(颜色=类))+
geom_smooth(
data =过滤器(mpg,==类“超紧凑型”),
se = FALSE
)
运行脚本的命令是:Rscript -e "rmarkdown::run('"D:/Test/testrmd.Rmd"', shiny_args = list(launch.browser = TRUE))"
,它是从命令行运行的
我得到了错误:
Error in loadNamespace(x) : there is no package called 'rmarkdown' Calls: loadNamespace -> withRestarts -> withOneRestart -> doWithOneRestart Execution halted
发布于 2021-09-30 18:38:21
你的代码文件没有任何闪亮的R代码,这只是一个Rmarkdown文件。Flexdashboard可以使用shiny,但默认情况下没有shiny。您需要runtime: shiny
(以及Rmarkdown包)来利用闪亮的功能。然后对我来说,我打开我的终端到我的.Rmd文件保存的目录,并运行约翰和你的建议,但我在Mac上,所以它是一个有点不同的Rscript -e "rmarkdown::run('delete.Rmd', shiny_args=list(launch.browser=TRUE))"
…它渲染了Rmd文件,并用HTML文件自动启动了浏览器,太棒了!
---
title: "Test"
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: fill
runtime: shiny
---
```{r setup, include=FALSE}
库(Flexdashboard)
库(Tidyverse)
库(Rmarkdown)
```{r plot1}
ggplot(mpg,mapping = aes(x = displ,y= hwy)) +
Geom_point(映射=aes(颜色=类))+
geom_smooth(
data =过滤器(mpg,==类“超紧凑型”),
se = FALSE
)
发布于 2021-09-30 16:16:27
首先,确保安装了rmarkdown包。那就试试这个-
Rscript -e "library(rmarkdown); rmarkdown::run('"D:/Test/testrmd.Rmd"', shiny_args = list(launch.browser = TRUE))
如果出现错误,请尝试install.packages("rmarkdown")
,然后运行上面的步骤
https://stackoverflow.com/questions/69392919
复制相似问题