I have a character vector in R, (named q2) where each observation is a person's response to an open-ended question on a survey. Briefly, how do I tell R to save each person's response as a text file? E.g., "file01.txt" "file02.txt" etc. for all cases?
Is there a more efficient or better way than this?
for(i in 1:length(q2)) {
filename <- paste("file",i,".txt", sep="")
writeLines(as.character(q2[i]), con=filename)
}