Skip to content

Problem in appending a row to *.csv file

3 messages · venkata kirankumar, Kenn Konstabel, David Winsemius

#
Looking at your question, I found myself wondering if you really  
wanted to do this at all. It appeared so much like inefficient habits  
acquired in the years of BASIC and Excel use. If you are interested in  
storing a dataframe to disk and then bringing it back into an R  
session, then the save and load functions are more appropriate.

Append works on vectors (and apparently on lists although the append  
help page does not document that behavior), but will probably not have  
the desired effect on dataframes.

Look instead at the rbind function if you are interested in adding row- 
wise to a dataframe.

 > tail(DF)
    Month Week Estpassage MedFL
8    Aug   34     358541    35
9   Sept   35     747839    35
10  Sept   36     459682    36
11  Sept   37     609567    36
12  Sept   38     979475    36
13  Sept   39     837189    36
 > tail( rbind(DF, c("Aug", 36, 555, 44)) )
    Month Week Estpassage MedFL
9   Sept   35     747839    35
10  Sept   36     459682    36
11  Sept   37     609567    36
12  Sept   38     979475    36
13  Sept   39     837189    36
14   Aug   36        555    44