我有这个代码来读取多个csv文件。
path <- "C:/Users/cfees/My Box Files/Fitness/"
files <- list.files(path=path, pattern="myfile_.+\\.csv")
我想在每次迭代中加载一个for c look每个csv。
我尝试一种简单的方法从列表中读取第一个csv文件但我收到错误。
df <- read.csv(path+files[1])
Error in path + files[1] : non-numeric argument to binary operator
我能做什么?
好的做法是使用file.path
来连接路径,它将处理以/
结尾的路径,更强大:
df <- read.csv(file.path(path,files[1]))