I am using R. I have a series of txt files that all all ;
seperated. I want to combined those files into 1 data frame. Each individual file has the variable names in the top row.
I found a useful post for doing this online. How to import multiple .csv files at once?. I am using rbindlist
to do this, though I am open to suggestions if there is an easier way to import this data.
Here is my code.
# create list of files
temp <- NULL
temp <- as.list (list.files ("F:/Desktop/data"))
temp
# now rbind the list using rbindlist
data <- NULL
data <- rbindlist(temp, fill=FALSE, idcol=NULL)
is.list (temp)
typeof (temp)
When I run this code, I get an error
Error in rbindlist(temp, fill = FALSE, idcol = NULL) :
Item 1 of input is not a data.frame, data.table or list
However, when I check temp using is.list and typeof, it shows up as a list. I am not sure why rbindlist isn't reading the list as a list. Is rbindlist the best way to import this data.