因此,我正在为Coursera课程的R课程作业。For循环仅适用于最后一个索引号
我正在使用for循环尝试创建一个数据框,该数据框结合了332个csv文件的数据。 for循环仅返回最后一个(第332个)csv文件的数据帧。 我在做什么错?
corr <- function(directory, threshold = 0) {
files <- Sys.glob("specdata//*.csv")
## Create empty numeric vector to append the nitrate values
nitr <- numeric()
## Create empty numeric vector to append the sulfate values
sulf <- numeric()
for (j in 1:length(files)) {
read.data <- read.csv(files[j])
}
}