I have over 1,000 .csv files in my directory. I need to select the first row (i.e. column names) of each of these files, and put them all into a new dataframe. Each .csv has a different number of columns.
Based on information from other stackoverflow questions, I've come up with this:
setwd("C:/Users/H300904/R project/files/CSV") file_list <- list.files(getwd()) field_names <- data.frame(df) for (file in file_list) { field_names <- read.csv(file="file", nrows=1, header=FALSE) }
I need help referencing 'file' correctly and telling it to put the data on the next row in the new dataframe. Any tips?
Thank you for sharing your knowledge with me.