Displaying 1 result from an estimated 1 matches for "newoutfil".
Did you mean:
newoutfile
2008 Aug 06
2
Index alternative to nasty FOR loop?
...ed to repeat this operation for each additional row (row 2, then row 3, etc) for 23 rows in each file.
I can do this with a for loop (as below).
Is there a way to use some of the indexing power of R to get around this nasty loop?
Thank you in advance for any suggestions
###################
newoutfile <- data.frame()
list <- list.files("c:/data")
file = 1
for(file in list) {
row <- file[1, ]
newoutfile <- rbind(row, newoutfile)
file = file + 1
write.csv(outfile, file = "output.csv")
}
####################
[[alternative HTML version deleted]]