[R] parsing problem
Ken Knoblauch
ken.knoblauch at inserm.fr
Mon Feb 2 13:38:38 CET 2009
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))
--
Ken Knoblauch
Inserm U846
Institut Cellule Souche et Cerveau
Département Neurosciences Intégratives
18 avenue du Doyen Lépine
69500 Bron
France
tel: +33 (0)4 72 91 34 77
fax: +33 (0)4 72 91 34 61
portable: +33 (0)6 84 10 64 10
http://www.sbri.fr
More information about the R-help
mailing list