[R] convert factor data to numeric

Nathalie Yauschew-Raguenes nathalie.yauschew-Raguenes at bordeaux.inra.fr
Wed Jan 13 18:00:35 CET 2010


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)



More information about the R-help mailing list