Re: [R] importing a list

From: Marc Schwartz (via MN) <mschwartz_at_mn.rr.com>
Date: Thu 11 May 2006 - 04:41:02 EST

On Wed, 2006-05-10 at 13:19 -0500, Marc Schwartz (via MN) wrote:
> A search for the list2ascii() function, led me to this post by Mike
> Prager:
>
> http://finzi.psych.upenn.edu/R/Rhelp02a/archive/66335.html
>
> in which Mike specifically notes:
>
> "To write it to a file that can be read by R, I would suggest using
> "dput" instead."
>
>
> Thus, instead of using list2ascii() on your list object, use:
>
> sink("YourTextFile")
> dput(YourListObject)
> sink()
>
> You can then re-read the text file back into R using:
>
> source("YourTextFile")

Actually, quick correction here. That should be:

  NewListObject <- dget("YourTextFile")

dget() will enable simple assignment of the textual input, whereas source() will just evaluate it and assignment with source() creates a list object, unless you use:   

  NewListObject <- source("YourTextFile")$value

Marc



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 Received on Thu May 11 04:44:23 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Thu 11 May 2006 - 06:10:04 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.