[R] Converting charter string to vector of numbers

Turgidson epw at upenn.edu
Wed Mar 25 18:27:40 CET 2015

Apologies for bringing up an old topic, but I am not finding working answers. 
I am also an R newbie, so I'm still on the steep part of the learning curve.

I have a character string :  "0.5 1 2 3 4"

I need to convert it to a vector of numbers.  I get as far as strsplit(),
which gives me 

 "0.5" "1" "2" "3" "4"

this is still treated by R as a single item.  I need to get it to look like
this:  "0.5", "1", "2", "3", "4"

so that I can use as.numeric() and make it into a vector of numbers...   I
have been going mad because for text operations, commas and quotes are
loaded with meaning, and I keep going around in circles.

Any help would be appreciated



View this message in context: http://r.789695.n4.nabble.com/Converting-charter-string-to-vector-of-numbers-tp4705097.html
Sent from the R help mailing list archive at Nabble.com.

More information about the R-help mailing list