Skip to content
Prev 286954 / 398500 Next

Converting a string vector with names to a numeric vector with names

On Thu, Mar 1, 2012 at 12:28 PM, John C Nash <nashjc at uottawa.ca> wrote:
Here's one:

split = sapply(strsplit(pstr, split = "="), I);

pnum = as.numeric(split[2, ]);
names(pnum) = split[1, ];
b1    b2    b3
200.0  50.0   0.3

HTH

Peter