无法在命令行中 运行 R Shiny
Unable to run R Shiny in command line
我试图从命令行 运行 闪亮,但我做不到。我已经创建了一个演示闪亮文件,该文件是我尝试使用的命令,但出现以下错误:
---
title: "Test"
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: fill
---
```{r setup, include=FALSE}
library(flexdashboard)
library(tidyverse)
```
```{r plot1}
ggplot(mpg, mapping = aes(x = displ, y = hwy)) +
geom_point(mapping = aes(color = class)) +
geom_smooth(
data = filter(mpg, class == "subcompact"),
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
首先确保安装了 rmarkdown 软件包。然后试试这个 -
Rscript -e "library(rmarkdown); rmarkdown::run('"D:/Test/testrmd.Rmd"', shiny_args = list(launch.browser = TRUE))
如果错误仍然存在,请尝试 install.packages("rmarkdown")
然后 运行 上述步骤
您的代码文件没有任何 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}
library(flexdashboard)
library(tidyverse)
library(rmarkdown)
```
```{r plot1}
ggplot(mpg, mapping = aes(x = displ, y = hwy)) +
geom_point(mapping = aes(color = class)) +
geom_smooth(
data = filter(mpg, class == "subcompact"),
se = FALSE
)
```
我试图从命令行 运行 闪亮,但我做不到。我已经创建了一个演示闪亮文件,该文件是我尝试使用的命令,但出现以下错误:
---
title: "Test"
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: fill
---
```{r setup, include=FALSE}
library(flexdashboard)
library(tidyverse)
```
```{r plot1}
ggplot(mpg, mapping = aes(x = displ, y = hwy)) +
geom_point(mapping = aes(color = class)) +
geom_smooth(
data = filter(mpg, class == "subcompact"),
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
首先确保安装了 rmarkdown 软件包。然后试试这个 -
Rscript -e "library(rmarkdown); rmarkdown::run('"D:/Test/testrmd.Rmd"', shiny_args = list(launch.browser = TRUE))
如果错误仍然存在,请尝试 install.packages("rmarkdown")
然后 运行 上述步骤
您的代码文件没有任何 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}
library(flexdashboard)
library(tidyverse)
library(rmarkdown)
```
```{r plot1}
ggplot(mpg, mapping = aes(x = displ, y = hwy)) +
geom_point(mapping = aes(color = class)) +
geom_smooth(
data = filter(mpg, class == "subcompact"),
se = FALSE
)
```