[R] Print/Save/Cat/Write list

Ritwik Sinha ritwik.sinha at gmail.com
Sat Sep 30 16:10:13 CEST 2006


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,

Here is my version

platform i686-redhat-linux-gnu
arch     i686
os       linux-gnu
system   i686, linux-gnu
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

More information about the R-help mailing list