Hi, I would like to write a list to an ascii file. I tried the following y <- list(a = 1, b = c(TRUE,FALSE), c = "oops") save(y, file="y.data", ascii=TRUE) # Not satisfactory print does not have a file="" option cat cannot handle lists. write does not handle lists write.table converts it to a d.f Perhaps I could loop through the elements of a list and keep appending its elements to a file, but that will have a problem if any of the elements of the list is a list. I suppose there must be a simple function that does what I need. Sorry if I have missed anything obvious, my searches did not return anything useful. Thanks and regards, Ritwik. Here is my version platform i686-redhat-linux-gnu arch i686 os linux-gnu system i686, linux-gnu status major 2 minor 2.1 year 2005 month 12 day 20 svn rev 36812 language R -- Ritwik Sinha Graduate Student Epidemiology and Biostatistics Case Western Reserve University ritwik.sinha at gmail.com | +12163682366 | http://darwin.cwru.edu/~rsinha
try: sink("y.data") y sink() On 9/30/06, Ritwik Sinha <ritwik.sinha at gmail.com> wrote:> Hi, > > I would like to write a list to an ascii file. > I tried the following > > y <- list(a = 1, b = c(TRUE,FALSE), c = "oops") > save(y, file="y.data", ascii=TRUE) > # Not satisfactory > > print does not have a file="" option > cat cannot handle lists. > write does not handle lists > write.table converts it to a d.f > > Perhaps I could loop through the elements of a list and keep appending > its elements to a file, but that will have a problem if any of the > elements of the list is a list. I suppose there must be a simple > function that does what I need. Sorry if I have missed anything > obvious, my searches did not return anything useful. > > Thanks and regards, > Ritwik. > > Here is my version > > platform i686-redhat-linux-gnu > arch i686 > os linux-gnu > system i686, linux-gnu > status > major 2 > minor 2.1 > year 2005 > month 12 > day 20 > svn rev 36812 > language R > > -- > Ritwik Sinha > Graduate Student > Epidemiology and Biostatistics > Case Western Reserve University > ritwik.sinha at gmail.com | +12163682366 | http://darwin.cwru.edu/~rsinha > > ______________________________________________ > R-help at 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. >-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve?
thanks. Ritwik. On 9/30/06, jim holtman <jholtman at gmail.com> wrote:> try: > > sink("y.data") > y > sink() > > On 9/30/06, Ritwik Sinha <ritwik.sinha at gmail.com> wrote: > > Hi, > > > > I would like to write a list to an ascii file. > > I tried the following > > > > y <- list(a = 1, b = c(TRUE,FALSE), c = "oops") > > save(y, file="y.data", ascii=TRUE) > > # Not satisfactory > > > > print does not have a file="" option > > cat cannot handle lists. > > write does not handle lists > > write.table converts it to a d.f > > > > Perhaps I could loop through the elements of a list and keep appending > > its elements to a file, but that will have a problem if any of the > > elements of the list is a list. I suppose there must be a simple > > function that does what I need. Sorry if I have missed anything > > obvious, my searches did not return anything useful. > > > > Thanks and regards, > > Ritwik. > > > > Here is my version > > > > platform i686-redhat-linux-gnu > > arch i686 > > os linux-gnu > > system i686, linux-gnu > > status > > major 2 > > minor 2.1 > > year 2005 > > month 12 > > day 20 > > svn rev 36812 > > language R > > > > -- > > Ritwik Sinha > > Graduate Student > > Epidemiology and Biostatistics > > Case Western Reserve University > > ritwik.sinha at gmail.com | +12163682366 | http://darwin.cwru.edu/~rsinha > > > > ______________________________________________ > > R-help at 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. > > > > > -- > Jim Holtman > Cincinnati, OH > +1 513 646 9390 > > What is the problem you are trying to solve? >-- Ritwik Sinha Graduate Student Epidemiology and Biostatistics Case Western Reserve University ritwik.sinha at gmail.com | +12163682366 | http://darwin.cwru.edu/~rsinha
Check out ?dput On 9/30/06, Ritwik Sinha <ritwik.sinha at gmail.com> wrote:> Hi, > > I would like to write a list to an ascii file. > I tried the following > > y <- list(a = 1, b = c(TRUE,FALSE), c = "oops") > save(y, file="y.data", ascii=TRUE) > # Not satisfactory > > print does not have a file="" option > cat cannot handle lists. > write does not handle lists > write.table converts it to a d.f > > Perhaps I could loop through the elements of a list and keep appending > its elements to a file, but that will have a problem if any of the > elements of the list is a list. I suppose there must be a simple > function that does what I need. Sorry if I have missed anything > obvious, my searches did not return anything useful. > > Thanks and regards, > Ritwik. > > Here is my version > > platform i686-redhat-linux-gnu > arch i686 > os linux-gnu > system i686, linux-gnu > status > major 2 > minor 2.1 > year 2005 > month 12 > day 20 > svn rev 36812 > language R > > -- > Ritwik Sinha > Graduate Student > Epidemiology and Biostatistics > Case Western Reserve University > ritwik.sinha at gmail.com | +12163682366 | http://darwin.cwru.edu/~rsinha > > ______________________________________________ > R-help at 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. >