Skip to content

conversion factor into numeric

4 messages · Smit, R. (Robin) (IenT), Koen Pelleriaux, Dimitris Rizopoulos +1 more

#
Robin,
It will work if you use decimal points (not comma)

HTH
Koen
On 5/6/05, Smit, R. (Robin) (IenT) <robin.smit at tno.nl> wrote:

  
    
#
I presume that in the place of "1,020" you need "1.02". Then use 
something like this:

mass <- factor(c("800", "1,020", "1,130", "1,250"))
as.numeric(gsub(",", ".", as.character(mass)))

I hope it helps.

Best,
Dimitris

----
Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/16/336899
Fax: +32/16/337015
Web: http://www.med.kuleuven.ac.be/biostat/
     http://www.student.kuleuven.ac.be/~m0390867/dimitris.htm


----- Original Message ----- 
From: "Smit, R. (Robin) (IenT)" <robin.smit at tno.nl>
To: <r-help at stat.math.ethz.ch>
Sent: Friday, May 06, 2005 2:17 PM
Subject: [R] conversion factor into numeric
#
Dimitris Rizopoulos wrote:
In this context I believe that "1,020" means "1020" in which case the
gsub call could be as.numeric(gsub(",", "", levels(mass)))[mass]