Dear Friends.

Greetings!

I have asked the question of how to set up a blank file and write a list to
it as a row for many times, with the number of lists unknown.

I have received many beautiful solutions.  Thanks go to Professor *Murdoch,
Professor *Menne, Professor Grothendieck and Dr. Olshansky.  I have
organized the solutions below:



##########################################

*Set up a blank table in harddrive and write to it row by row*

*#Method 1*

*blank = data.frame(name=character(0), wife=character(0),
no.children=numeric(0))*

write.csv(blank, 'file1.csv', row.names=FALSE)

a1 = list(name="Tom", wife="Joy", no.children=9)

a2 = list(name="Paul", wife="Alic", no.children=5)

write.table(a1, file="file1.csv", sep=',', append=TRUE, row.names=FALSE,
col.names=FALSE)

write.table(a2, file="file1.csv", sep=',', append=TRUE, row.names=FALSE,
col.names=FALSE)**

*
*

*#Method 2*

*blank = data.frame(name=character(0), wife=character(0),
no.children=numeric(0))*

write.csv(blank, 'file2.csv')

a1 = list(name="Tom", wife="Joy", no.children=9)

a2 = list(name="Paul", wife="Alic", no.children=5)

write.table(a1, file="file2.csv", sep=',', append=TRUE, row.names=2,
col.names=FALSE)

write.table(a2, file="file2.csv", sep=',', append=TRUE, row.names=3,
col.names=FALSE)**

#######################################

My problem now is, how to write a time series (instead of a list) to a csv
file? Also, how to set up such a csv file to accept the time series?

I know the length of the time series' but I do not know how many of them are
going to come up.

Examples are :

bb1=c(1:10)

bb2=c(101:110)

How to write bb1 and bb2 to a csv file and how to set up blank csv file to
accept such time series in the first place?

Your help will be highly appreciated!!!

Best Wishes!

Yuchen Luo

        [[alternative HTML version deleted]]

______________________________________________
R-help@stat.math.ethz.ch 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.

Reply via email to