如何解决 R 中此处包的路径问题?

How to resolve issue with path with here package in R?

我有以下代码用于从名为 RawData 的目录中获取 4 个 csv 文件并使用 rbind 合并行,效果很好

library(data.table)

setwd("C:/Users/Gunathilakel/Desktop/Vera Wrap up Analysis/Vera_Wrapup_Analysis/RawData")  

myMergedData <- 
  do.call(rbind,
          lapply(list.files(path = getwd()), fread))

但是,我想确保此代码可在另一台计算机上重现,因此决定删除 setwd。所以我决定使用 here 包并实现相同的过程

library(here)


myMergedData <- 
  do.call(rbind,
          lapply(list.files(path = here("RawData")), fread))

当我 运行 上述脚本时,它会给出以下消息

Taking input= as a system command ('Issued and Referral Charge-2019untildec25th.csv') and a variable has been used in the expression passed to `input=`. Please use fread(cmd=...). There is a security concern if you are creating an app, and the app could have a malicious user, and the app is not running in a secure environment; e.g. the app is running as root. Please read item 5 in the NEWS file for v1.11.6 for more information and for the option to suppress this message. 'Issued' is not recognized as an internal or external command, operable program or batch file.

list.files 调用将 return 文件名 Issued and Referral Charge-2019untildec25th.csv 不带路径。你需要

list.files(path = here("RawData"), full.names = TRUE)

这样你也能得到路径,fread就能找到文件。