【问题标题】:Knitr from linux command line来自 linux 命令行的 Knitr
【发布时间】:2017-11-03 04:31:35
【问题描述】:

我有一个非常简单的 knitr 脚本。它与我的 Windows 笔记本电脑上的 rstudio 完美配合。

---
title: "Descriptives and PCA"
output:
pdf_document: default
html_document: default
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE, warning=FALSE, message=FALSE)
```
#TEST

```{r}
print(getwd())
```

我使用以下脚本在 linux 集群上运行脚本

cd ./__workspace/R/pipeline
Rscript -e "library(knitr); stitch('pipelineDescriptive.Rmd')"

它不起作用。它打印出一个 pdf,它只是 Rmd 文件代码的副本。

控制台打印出以下两个问题:

|................................                                 |  50%
label: auto-report
Error in parse(text = code, keep.source = FALSE) :
  attempt to use zero-length variable name
|.........................................                        |  62%

Warning message:
In highr::hilight(x, format, prompt = options$prompt, markup = opts$markup) :
  the syntax of the source code is invalid; the fallback mode is used

有人对如何解决这个问题有任何建议吗?

【问题讨论】:

  • 几个 cmets:1) 使用 stitch_rmd 然后 50 % 的错误应该消失。 2) 为什么不使用Rscript -e "library(markdown); render('pipelineDescriptive.Rmd')"
  • 有效!也许你可以发布作为答案。值得点赞。注意,我认为库是 rmarkdown 渲染是 rmarkdown::render
  • 是的,应该是rmarkdown

标签: r linux knitr


【解决方案1】:

我建议使用library(rmarkdown) 然后

Rscript -e "rmarkdown::render('pipelineDescriptive.Rmd')"

如果你想使用library(knitr):

Rscript -e "knitr::stitch_rmd('pipelineDescriptive.Rmd')"

【讨论】:

    猜你喜欢
    • 2020-10-02
    • 1970-01-01
    • 1970-01-01
    • 2015-09-05
    • 1970-01-01
    • 2015-03-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多