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

2012-03-01 Thread John C Nash
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)

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

2012-03-01 Thread Petr Savicky
On Thu, Mar 01, 2012 at 03:28:31PM -0500, John C Nash wrote: > Not paying close attention to detail, I entered the equivalent of > > pstr<-c("b1=200", "b2=50", "b3=0.3") > > when what I wanted was > > pnum<-c(b1=200, b2=50, b3=0.3) > > There was a list thread in 2010 that shows how to deal with

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

2012-03-01 Thread Peter Langfelder
On Thu, Mar 1, 2012 at 12:28 PM, John C Nash wrote: > Not paying close attention to detail, I entered the equivalent of > > pstr<-c("b1=200", "b2=50", "b3=0.3") > > when what I wanted was > > pnum<-c(b1=200, b2=50, b3=0.3) > > There was a list thread in 2010 that shows how to deal with un-named ve

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

2012-03-01 Thread John C Nash
Not paying close attention to detail, I entered the equivalent of pstr<-c("b1=200", "b2=50", "b3=0.3") when what I wanted was pnum<-c(b1=200, b2=50, b3=0.3) There was a list thread in 2010 that shows how to deal with un-named vectors, but the same lapply solution doesn't seem to work here i.e.