r - 从命令提示符在 .Rmd 上运行 .Rexec
问题描述
所以我按照这个博客创建了一个名为 r2jekyll 的可执行文件
不幸的是,我在 Windows 上,所以我不得不以不同的方式创建名为 r2jekyll 的 .Rexec
r2jekyll 的代码在这里:
#!/usr/bin/env Rscript
library(knitr)
# Get the filename given as an argument in the shell.
args = commandArgs(TRUE)
filename = args[1]
# Check that it's a .Rmd file.
if(!grepl(".Rmd", filename)) {
stop("You must specify a .Rmd file.")
}
# Knit and place in _posts.
dir = paste0("../_posts/", Sys.Date(), "-")
output = paste0(dir, sub('.Rmd', '.md', filename))
knit(filename, output)
# Copy .png files to the images directory.
fromdir = "{{ site.url }}/images"
todir = "../images"
pics = list.files(fromdir, ".png")
pics = sapply(pics, function(x) paste(fromdir, x, sep="/"))
file.copy(pics, todir)
unlink("{{ site.url }}", recursive = TRUE)
一切正常,我可以运行我的 r2jekyll rexec(感谢这个博客)它运行但没有任何反应
我已经到了在名为 first_test.Rmd 的文件上运行 r2jekyll 的最后一步
我在命令提示符下运行以下代码
cd (go to directory where my r2jekyll and my first_test.Rmd are sitting)
然后
r2jekyll.rexec first_test.Rmd (the blog author used this code, he is on a mac)
我收到以下错误
错误:您必须指定一个 .Rmd 文件。执行停止
所以我的问题是:我如何让我的 r2jekyll.Rexec 对 first_test.Rmd 做它的事情
解决方案
推荐阅读
- querydsl - 我可以使用 queryDSL 添加条件字段吗?(如mybatis)
- swift - 如何使用 ARKit 和 RealityKit 检测 2D 图像?
- node.js - 我得到一个 TypeError: mongoose.model is not a function。我如何解决它?
- ejabberd - ejabberdctl mod_http_bind 模块不可用
- c# - double value 使用 Dapper DynamicParameters 保存到 MS SQL 后删除比例值
- html - 在子组件中使用 *ngIf 动态更改类
- sql - 如何在 Amazon Athena 中查询 json?
- python - 如何从文本文件中保存特定数据并使用 python 保存结果数据
- android - Android当活动失去焦点并被通知带回来时,声音将不再播放
- node.js - 对 node_modules 中的文件进行更改是否会重新启动 nodemon?