[R] Converting a string vector with names to a numeric vector with names

John C Nash nashjc at uottawa.ca
Thu Mar 1 22:36:32 CET 2012


Gotta love R.

Thanks to Bill Dunlap, Peter Langfelder and Jim Holtman for no less than 3 different 
solutions.

JN


On 12-03-01 04:25 PM, Peter Langfelder wrote:
> pstr<-c("b1=200", "b2=50", "b3=0.3")

> split = sapply(strsplit(pstr, split = "="), I);
>
> pnum = as.numeric(split[2, ]);
> names(pnum) = split[1, ];
>



More information about the R-help mailing list