Skip to content
Back to formatted view

Raw Message

Message-ID: <6EE447FE-AFA2-4BA0-9599-47C07CA6E945@me.com>
Date: 2011-04-19T21:11:08Z
From: Marc Schwartz
Subject: Simple question
In-Reply-To: <4DADF9CD.6010009@xtra.co.nz>

On Apr 19, 2011, at 4:08 PM, Rolf Turner wrote:

> On 20/04/11 07:19, Steven Wolf wrote:
>> I am trying to convert a string to a vector, and I'm stuck!
>> 
>> 
>> 
>> Suppose you have a string of numbers (string) that you want to convert to a
>> vector (vec).  I am able to split the string turning it into a list by using
>> strsplit, but this makes a list, which I can't seem to access the way that
>> I'd like to (it becomes a character list of only one(?!?) element.)
>> 
>> 
>> 
>> string<-"1,1,2,3,5,8"
>> 
>> 
>> 
>> list<-strsplit(string,",")
>> 
>> list # Produces this ugly output with the [[1]] crap which doesn't let me
>> in!!!!!!!
>> 
>> 
>> 
>> vec<-c(1,1,2,3,5,8)  # All I really want in the end.
> 


> <SNIP>
> 
> It sounds to me like you don't understand lists.  If you are going to use
> R you really should understand them.  They are a wonderfully useful
> concept and make doing many otherwise complex tasks an absolute
> breeze.  Learn to love lists.  It will be rewarding! :-)


Fortunes candidate....  :-)

Cheers,

Marc Schwartz