我试图根据以下教程在R Markdown中创建参数化报告:http://rmarkdown.rstudio.com/developer_parameterized_reports.html#passing-parameters
我正在尝试使用render从r控制台传递文件路径作为参数。就像这样:
render('rmarkdownfile.rmd',params= list( client= "clientdata.csv"))
我的Markdown文件看起来像这样:
title: "Liquidity Report"
output: pdf_document
params: client:"clientdata.csv"
---
```{r plot, echo=FALSE, warning=FALSE}
cftest <- read.csv(params$client)
但是我收到了一个错误,它说:
read.table(file=file, header=header, sep=sep, quote=quote,)中的错误:'file'必须是字符字符串或连接。调用:
看起来 Markdown 没有识别参数,尽管我按照教程的步骤进行操作。是否有人能够成功地在 R Markdown 中使用参数?
另外,我正在遵循教程的建议,并使用 R Studio 预览以及最新版本的 r markdown 和 knitr。
谢谢您的帮助!
Rafael
Rscript -e“rmarkdown :: render('./testreport.Rmd',params = list(directory ='/ PATHTO / geneticstuff /', lqual ='finches_stats.lqual', ldepth.mean ='finches_stats.ldepth.mean', lmiss ='finches_stats.lmiss', fq ='finches_stats.frq', idepth ='finches_stats.idepth', imiss ='finches_stats.imiss'))"
- M. Beausoleil参数: 目录: 值:x lqual: 值:x ldepth.mean: 值:x lmiss: 值:x fq: 值:x idepth: 值:x imiss: 值:x
这些被放在不同的行上。因此,您可以将每个“文件”用作新的params$file
放入R脚本中! - M. Beausoleilpaste
函数更改为file.path
。 - M. Beausoleilvalue: x
行是默认值。在这种情况下,我使用x
来创建一个占位符,并确保呈现调用在没有有效的目录和文件路径的情况下失败。 - Paul James