更新时间:2023-01-02 09:23:21
删除扩展名"csv",然后添加"Rdata",并在循环中使用文件名,例如:
Drop the extension "csv", then add "Rdata", and use filenames in the loop, for example:
myFiles <- list.files(pattern = "\\.csv$")
for(i in myFiles){
myDf <- read.csv(i)
outputFile <- paste0(tools::file_path_sans_ext(i), ".Rdata")
outputFile <- gsub("nE_pT_", "e_", outputFile, fixed = TRUE)
save(myDf, file = outputFile)
}
注意:我更改了您的变量名,请尽量避免将函数名用作变量名.
Note: I changed your variable names, try to avoid using function names as a variable name.