Nikola Pejakovic
Nikola Pejakovic

Reputation: 23

How to write a text before saving a data frame?

So I want to insert a text before saving my data frame. For example I used following:

    txt<-("The following data is the sum of PRCP, Snow and EvTr
            Date                SumPRCP")
    writeLines(txt, "Maille6412.txt")   

Than I used following code to save data frame.

 write.table(Maille,file="Maille6412.txt", sep=" ", quote = F,col.names = F, row.names = F)

These two lines are overwriting each other can someone tell me the method of writing the lines before a data frame.

Upvotes: 1

Views: 76

Answers (1)

user2100721
user2100721

Reputation: 3587

Add append = TRUE within write.table

write.table(Maille,file="Maille6412.txt", sep=" ", quote = F,col.names = F, row.names = F,append = TRUE)

Upvotes: 1

Related Questions