[R] convert list to text file

Greg Snow 538280 at gmail.com
Sat Mar 3 00:46:24 CET 2012


Or

lapply(LIST, cat, file='outtext.txt', append=TRUE)

On Thu, Mar 1, 2012 at 6:20 AM, R. Michael Weylandt
<michael.weylandt at gmail.com> wrote:
> Perhaps something like
>
> sink("outtext.txt")
> lapply(LIST, print)
> sink()
>
> You could replace print with cat and friends if you wanted more
> detailed control over the look of the output.
>
> Michael
>
> On Thu, Mar 1, 2012 at 5:28 AM,  <T.Galesloot at ebh.umcn.nl> wrote:
>> Dear R users,
>>
>> Is it possible to write the following list to a text-file?
>>
>> List:
>>
>> [[1]]
>> [1] 500
>>
>> [[2]]
>> [1] 1
>>
>> [[3]]
>>    [,1] [,2] [,3] [,4] [,5]
>> FID    1    2    3    4    5
>> Var    2    0    2    1    1
>>
>> I would like to have the textfile look like this:
>>
>> 500
>> 1
>> FID 1 2 3 4 5
>> Var 2 0 2 1 1
>>
>> Thank you very much in advance for your help!
>>
>> Kind regards,
>>
>> Tessel Galesloot
>> Department of Epidemiology, Biostatistics and HTA (133)
>> Radboud University Nijmegen Medical Centre
>>
>>
>>
>> Het UMC St Radboud staat geregistreerd bij de Kamer van Koophandel in het handelsregister onder nummer 41055629.
>> The Radboud University Nijmegen Medical Centre is listed in the Commercial Register of the Chamber of Commerce under file number 41055629.
>>
>> ______________________________________________
>> R-help at r-project.org 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.
>
> ______________________________________________
> R-help at r-project.org 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.



-- 
Gregory (Greg) L. Snow Ph.D.
538280 at gmail.com



More information about the R-help mailing list