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

______________________________________________
R-help@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.

Reply via email to