How can I write out multiple files with different filenames in R
I have one BIG file (>10000 lines of data) and I want write out a separate file by ID. I have 50 unique ID names and I want a separate text file for each one. Here's what Ive got so far, and I keep getting errors. My ID is actually character string which I would prefer if I can name each file after that character string it would be best. for (i in 1:car$ID) { a <- data.frame(car[,i]) carib <- car1[,(c("x","y","time","sd"))] myfile <- gsub("( )", "", paste("C:/bridge", carib, "_", i, ".txt")) write.table(a, file=myfile, sep="", row.names=F, col.names=T quote=FALSE, append=FALSE) } One approach