Re: [Rd] String to list and visa versa

From: Prof Brian Ripley <>
Date: Wed 15 Nov 2006 - 05:00:28 GMT

On Tue, 14 Nov 2006, Vladimir Dergachev wrote:

> On Tuesday 14 November 2006 12:28 pm, Prof Brian Ripley wrote:
>> This approach won't work in very many cases (but then nor will write.csv).
>> The safest way I know is to use serialize() and unserialize(). Next to
>> that, deparse(control="all") and parse(text=) are quite good and give a
>> human-readable character representation.
>> If fidelity is not the main issue, as.character and toString spring to
>> mind. unlist is recursive, and is not going to come close to being
>> faithful for other than very simple lists. And what if ',' is a character
>> in one of the list elements?
> Yes, but then one can replace ',' with something rarely used like \007.
> I picked ',' because write.csv/read.csv worked before.

But it quotes strings ....

> You are right, for storage serialize/unserialize seem best, however for
> manipulation one would usually prefer a well-defined format.

Brian D. Ripley,        
Professor of Applied Statistics,
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________ mailing list
Received on Thu Nov 16 00:42:09 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 Wed 15 Nov 2006 - 16:30:44 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.