My data: I have longitudinal data for a few hundred subjects and the program spit out the datafiles in the format of week.subjectID.csv. For example, 1.100.csv is the file for week 1 of subject 100.
My problem: Using the post at the end, I figured out how to read in multiple files and combine them (code below).
library(plyr)
#Create list of all weekly files for subject ID 100
files = list.files(pattern="*.100.csv")
#List of data frames
subject = lapply(files, read.delim)
#Throw them altogether
exporty = ldply(subject, data.frame)
#Export new file
write.csv(exporty, "100")
However, this process is quite slow when having to repeat this command for all of my subjects. Is there a way to create a list of my subjects and, one subject at a time, read in their files, combine them, export their combined dataset, and then move onto the next subject?
Resource: Importing multiple .csv files into R