From tom.mccallum at levelelimited.com  Wed Nov 15 11:52:00 2006
From: tom.mccallum at levelelimited.com (Tom McCallum)
Date: Wed, 15 Nov 2006 10:52:00 -0000
Subject: [Rd] String to list and visa versa
In-Reply-To: <Pine.LNX.4.64.0611150458200.32548@gannet.stats.ox.ac.uk>
References: <op.ti0mvjx2ffxks9@norisk>
	<200611141209.22173.vdergachev@rcgardis.com>
	<Pine.LNX.4.64.0611141717350.22401@gannet.stats.ox.ac.uk>
	<200611141646.06213.vdergachev@rcgardis.com>
	<Pine.LNX.4.64.0611150458200.32548@gannet.stats.ox.ac.uk>
Message-ID: <op.ti10gyyuffxks9@norisk>

On Wed, 15 Nov 2006 05:00:28 -0000, Prof Brian Ripley  
<ripley at stats.ox.ac.uk> wrote:

> 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.
>
>

Thanks for the information, I think I am going to use the  
serialize/unserialize methods, which will mean I can't manipulate them  
outside R, but I can alter other parts of the project to accomodate this.

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 c...{{dropped}}



[Rd] String to list and visa versa
Tom McCallum