默认情况下,reprex 强烈鼓励在会话临时目录中执行。但有时不可避免地要引用特定的本地文件,所以是的,必须有一种方法来做到这一点。
要求所有工作在当前工作目录, set outfile = NA
。 (更一般地,您可以使用outfile
指定基本文件名和路径的参数。)
如果我提交此 reprex,并将工作目录设置为我的主目录:
reprex({
getwd()
writeLines(c("V1,V2","a,b"), "precious_data.csv")
list.files(pattern = "*.csv")
read.csv("precious_data.csv")
},
outfile = NA,
venue = "so"
)
我得到这个输出:
getwd()
#> [1] "/Users/jenny"
writeLines(c("V1,V2","a,b"), "precious_data.csv")
list.files(pattern = "*.csv")
#> [1] "precious_data.csv"
read.csv("precious_data.csv")
#> V1 V2
#> 1 a b
Created on 2018-09-19 by the reprex package https://reprex.tidyverse.org (v0.2.1)
Using outfile = NA
or outfile = "path/to/desired/file/base"
是对由以下命令生成的所有文件的位置进行断言控制的通用模式reprex()
.