我有以下代码,用于从名为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
调用将返回文件名Issued and Referral Charge-2019untildec25th.csv
,但不包含其路径。您需要
list.files(path = here("RawData"), full.names = TRUE)
这样您也可以获得路径,并且fread
将能够找到该文件。