Skip to content

Print/Save/Cat/Write list

4 messages · jim holtman, Ritwik Sinha, Gabor Grothendieck

#
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
#
try:

sink("y.data")
y
sink()
On 9/30/06, Ritwik Sinha <ritwik.sinha at gmail.com> wrote:

  
    
#
thanks.

Ritwik.
On 9/30/06, jim holtman <jholtman at gmail.com> wrote:

  
    
#
Check out ?dput
On 9/30/06, Ritwik Sinha <ritwik.sinha at gmail.com> wrote: