Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to add to a file, rather than overwrite using write.csv

Tags:

r

csv

simple question - I am using the write.csv function in R:

write.csv(t(y), file = "test.csv")

Where y is a dataframe of a file in my directory

However, I have many files in my directory, and I want the output of each file to be written to "test.csv" by using a loop. However, just testing this out I notice that if I write to test.csv, and then repeat the command with another file, instead of adding it overwrites test.csv instead of adding to it.

so my question is how to I add to test.csv rather than overwrite it.

Thanks very much.

like image 553
brucezepplin Avatar asked Mar 24 '23 16:03

brucezepplin


1 Answers

write.csv(t(y), file = "test.csv", append=TRUE)

should do it.

like image 95
user1981275 Avatar answered Apr 06 '23 00:04

user1981275