Hi all, I am new to R-project I have a problem when when ever I am going to append a row in a *.csv file that is in R-project I created one dataframe and I saved it in "res.csv" and again I got some results in dataframe with same column names and i tried to append in a new row of same "res.csv" file but its appending again with columnnaes like first time when i created the csv file "","max","min","avg" "1",22,7,12.9833333333333 and when I try to append another column for this file its writing like "","max","min","avg" "1",22,7,12.9833333333333 "","max","min","avg" "1",19,7,12.9918699186992 can any one suggest how to solve this problem and how can I save new rows without taking column names and also i tried with "append()" function to append to dataframes then also its giving the same result thanks in advance [[alternative HTML version deleted]]
For some clever reason, write.csv won't let you set col.names argument to FALSE, but you can use it with write.table using sep=",". A self-contained, minimal, and working example: write.csv(matrix(1:10,2,5), "test.csv") write.table(matrix(11:20,2,5), "test.csv", sep=",", append=TRUE, col.names=FALSE) Regards, KK On Mon, Feb 9, 2009 at 12:17 PM, venkata kirankumar <kiran4u2all@gmail.com>wrote:> Hi all, > I am new to R-project > I have a problem when when ever I am going to append a row in a *.csv file > that is > in R-project I created one dataframe and I saved it in "res.csv" and again > I got some results in dataframe with same column names and i tried to > append > in a new row of same "res.csv" file but its appending again with > columnnaes like > > > > first time when i created the csv file > > "","max","min","avg" > "1",22,7,12.9833333333333 > > and when I try to append another column for this file its writing like > > "","max","min","avg" > "1",22,7,12.9833333333333 > "","max","min","avg" > "1",19,7,12.9918699186992 > > > can any one suggest how to solve this problem > and how can I save new rows without taking column names > > > and also i tried with "append()" function to append to dataframes then > also its giving the same result > > thanks in advance > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]
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 -- David Winsemius On Feb 9, 2009, at 5:17 AM, venkata kirankumar wrote:> Hi all, > I am new to R-project > I have a problem when when ever I am going to append a row in a > *.csv file > that is > in R-project I created one dataframe and I saved it in "res.csv" > and again > I got some results in dataframe with same column names and i tried > to append > in a new row of same "res.csv" file but its appending again with > columnnaes like > > > > first time when i created the csv file > > "","max","min","avg" > "1",22,7,12.9833333333333 > > and when I try to append another column for this file its writing like > > "","max","min","avg" > "1",22,7,12.9833333333333 > "","max","min","avg" > "1",19,7,12.9918699186992 > > > can any one suggest how to solve this problem > and how can I save new rows without taking column names > > > and also i tried with "append()" function to append to > dataframes then > also its giving the same result > > thanks in advance > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.