hello could you give me a hint to convert data in factor type to numeric (float) ? regards -- Open WebMail Project (http://openwebmail.org)
This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean.
7 messages · Ahmet Temiz, Dimitris Rizopoulos, S Devriese +3 more
hello could you give me a hint to convert data in factor type to numeric (float) ? regards -- Open WebMail Project (http://openwebmail.org)
This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean.
check the following: http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-do-I-convert-factors-to-numeric_003f Best, Dimitris
hello could you give me a hint to convert data in factor type to numeric (float) ? regards -- Open WebMail Project (http://openwebmail.org)
Dimitris Rizopoulos Assistant Professor Department of Biostatistics Erasmus University Medical Center Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands Tel: +31/(0)10/7043478 Fax: +31/(0)10/7043014
hello could you give me a hint to convert data in factor type to numeric (float) ? regards -- Open WebMail Project (http://openwebmail.org)
you could try as.numeric but without more details it is difficult to see if this will work. How did you end up with a factor (e.g. through import)? Stephan
On 01/13/2010 10:47 AM, Ahmet Temiz wrote:
hello could you give me a hint to convert data in factor type to numeric (float) ? regards -- Open WebMail Project (http://openwebmail.org)
you could try as.numeric but without more details it is difficult to see if this will work. How did you end up with a factor (e.g. through import)?
No, don't use as.numeric(). Do follow Dimitris' advice. But the question of how you got the factor data is good; you can usually avoid getting factors to begin with. -Peter Ehlers
Stephan
______________________________________________ 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.
Peter Ehlers University of Calgary 403.202.3921
Hello, I find a way to convert data in factor type to numeric : data_numeric <- as.numeric(as.character(data_factor)). It's treaky but works. Peter Ehlers a ?crit :
S Devriese wrote:
On 01/13/2010 10:47 AM, Ahmet Temiz wrote:
hello could you give me a hint to convert data in factor type to numeric (float) ? regards -- Open WebMail Project (http://openwebmail.org)
you could try as.numeric but without more details it is difficult to see if this will work. How did you end up with a factor (e.g. through import)?
No, don't use as.numeric(). Do follow Dimitris' advice. But the question of how you got the factor data is good; you can usually avoid getting factors to begin with. -Peter Ehlers
Stephan
______________________________________________ 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.
Nathalie YAUSCHEW-RAGUENES Ph.D Student Unit? de Recherches Ecologie Fonctionnelle et Physique de l'Environnement (EPHYSE)
S Devriese wrote:
On 01/13/2010 10:47 AM, Ahmet Temiz wrote:
hello could you give me a hint to convert data in factor type to numeric (float) ? regards -- Open WebMail Project (http://openwebmail.org)
you could try as.numeric but without more details it is difficult to see if this will work. How did you end up with a factor (e.g. through import)?
No, don't use as.numeric(). Do follow Dimitris' advice. But the question of how you got the factor data is good; you can usually avoid getting factors to begin with. -Peter Ehlers
Stephan
______________________________________________ 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.
I know, slightly sloppy answer (see Dimitri's answer), but I hoped to find out how he got the factor in the first place, because if it is an import issue (and e,g. decimal character is different from the locale decimal character) the FAQ answer might not work as expected. Stephan
Hello, I find a way to convert data in factor type to numeric : data_numeric <- as.numeric(as.character(data_factor)). It's treaky but works.
Possibly even more ``treaky'' but more efficient is:
data_numeric <- as.numeric(levels(data_factor)[data_factor])
as has been pointed out quite a few times on this list.
cheers,
Rolf Turner
######################################################################
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}