Ken Knoblauch <ken.knoblauch <at> inserm.fr> writes: > > venkata kirankumar <kiran4u2all <at> gmail.com> writes: > > I am trying to parse a vector for caliculating minimum in that vector the > > vector having values like > > > > 1 Kontrolle > > 2 Placebo > > 3 125mg/kg > > 4 250mg/kg > > 5 500mg/kg > > 6 1000mg/kg > > hear i tries for comverting it into numeric with using "as.numaric()" > > function > > but i got values like > > 5 > > 6 > > 2 > > 3 > > 4 > > 1 > > > > can anyone suggest how I will solve it > > > > thanks in advance > > > > regards; > > kiran > > > Your Kontrolle is being treated as a factor so you > are seeing only the codes of the levels. There is > probably something more elegant, but you need > something like, > > as.numeric(sapply(with(dd, strsplit(levels(Placebo)[Placebo], "m")), "[[", 1)) > I should have specified that when I read in your data, my data frame looked like this dd X2 Placebo 1 3 125mg/kg 2 4 250mg/kg 3 5 500mg/kg 4 6 1000mg/kg and str(dd) 'data.frame': 4 obs. of 2 variables: $ X2 : int 3 4 5 6 $ Placebo: Factor w/ 4 levels "1000mg/kg","125mg/kg",..: 2 3 4 1
______________________________________________ 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.