I have seen lots of answers for this but when I have tried them, my dataframe is empty - "attempt to set an attribute on NULL"
setwd("*my path*")
library(ggplot2)
library(class)
set.seed(3060)
label<-11
index<-000
for(label in 11:37)
{
for(index in 000:419){
nameOfFile <- paste(label, index, "features.csv", sep = "_")
files <- list.files(path=getwd(), pattern=nameOfFile)
training <- do.call(rbind, lapply(files, read.csv, header=FALSE))
}
}
All of my csv files are of the same format - one row and 22 columns.
答案 0 :(得分:0)
might need to mess with this code a bit but you shouldn't need to loop to read files.
library(tidyverse)
do.call(bind_rows,
lapply(paste0("data_location/", list.files("data_location/")), read_csv))