[R] parsing problem

Nutter, Benjamin NutterB at ccf.org
Mon Feb 2 13:37:54 CET 2009



-----Original Message-----
From: Nutter, Benjamin 
Sent: Monday, February 02, 2009 7:37 AM
To: 'venkata kirankumar'
Subject: RE: [R] parsing problem

This is how I would approach it.  I'd be happy to know if there's a
better way.

#*** Initial Data Frame
x <-
c("Kontrolle","Placebo","125mg/kg","250mg/kg","500mg/kg","1000mg/kg"))
x

#*** Convert alphabetical and punctuation characters to "" (see ?regex)
y <- gsub("[[:alpha:],[:punct:]]","",x)
y

#*** Convert character strings to numeric
z <- as.numeric(y)
z

#*** Calculate minimum
min(df$z,na.rm=TRUE)




-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
On Behalf Of venkata kirankumar
Sent: Monday, February 02, 2009 7:18 AM
To: r-help at r-project.org
Subject: [R] parsing problem

Hi all,
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

it gives 1000mg/kg is the least one
but i have toget 125mg/kg as the minimum value
for that i have to remove all the strings and spetial charecters from
that
for that i used      "parse()"      but i am not able to get the out put

can anyone suggest how I will solve it


thanks in advance



regards;
kiran

	[[alternative HTML version deleted]]

______________________________________________
R-help at 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.


===================================

P Please consider the environment before printing this e-mail

Cleveland Clinic is ranked one of the top hospitals
in America by U.S. News & World Report (2008).  
Visit us online at http://www.clevelandclinic.org for
a complete listing of our services, staff and
locations.


Confidentiality Note:  This message is intended for use\...{{dropped:13}}




More information about the R-help mailing list