Hi, I need to collapse a list into a string and then reparse it back into the list. Normally when I need to do this I simply use write.csv and read.csv, but I need to do this in memory within R rather than writing out to file. Are there any bespoke commands that any knows of that does something like this or any tips for doing this that anyone can suggest? I basically don't care upon the string representation, only that I can manipulate the list as a string and then reparse it back to a valid list object. Many thanks for your help, Tom -- Dr. Thomas McCallum Systems Architect, Level E Limited ETTC, The King's Buildings Mayfield Road, Edinburgh EH9 3JL, UK Work +44 (0) 131 472 4813 Fax: +44 (0) 131 472 4719 http://www.levelelimited.com Email: tom at levelelimited.com Level E is a limited company incorporated in Scotland. The contents of this e-mail are privileged and/or confidential. If you are not the intended recipient, please notify the sender and ensure this e-mail is deleted and not read, copied or disclosed. It is your responsibility to scan this e-mail and any attachments for computer viruses or other defects. Level E does not accept liability for any loss or damage which may result from this e-mail or any attachment. E-mail is not secure and can be intercepted, corrupted or amended. Level E does not accept liability for errors or omissions arising as a result of interrupted or defective transmission. Any views, opinions, conclusions or other information in this e-mail which do not relate to the business of Level E Limited are not authorised by Level E. Unless specifically stated and authorised by Level E, nothing in this e-mail shall be taken to be an offer or acceptance of any contract of any nature. E-mail entering or leaving Level E's system is subject to random monitoring and recording.
On Tuesday 14 November 2006 12:00 pm, Tom McCallum wrote:> Hi, > > I need to collapse a list into a string and then reparse it back into the > list. Normally when I need to do this I simply use write.csv and > read.csv, but I need to do this in memory within R rather than writing out > to file. Are there any bespoke commands that any knows of that does > something like this or any tips for doing this that anyone can suggest? I > basically don't care upon the string representation, only that I can > manipulate the list as a string and then reparse it back to a valid list > object.#List -> string: # # Put whatever you want into collapse to separate list entries # paste(unlist(L), collapse=",") #String->list strsplit(S, ",") best Vladimir Dergachev> > Many thanks for your help, > > Tom
"Tom McCallum" <tom.mccallum at levelelimited.com> writes:> Hi, > > I need to collapse a list into a string and then reparse it back into the > list. Normally when I need to do this I simply use write.csv and > read.csv, but I need to do this in memory within R rather than writing out > to file.> Are there any bespoke commands that any knows of that does > something like this or any tips for doing this that anyone can > suggest?Er, perhaps you should send that sentence off to Iain McC.[*], so that we can find out what killed it. ;-)> I > basically don't care upon the string representation, only that I can > manipulate the list as a string and then reparse it back to a valid list > object.You might want to investigate deparse() and parse(). [*] http://www.johnhannah.net/mccallum.html -- O__ ---- Peter Dalgaard ?ster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907