[R] factor levels > numeric values
David L Carlson
dcarlson at tamu.edu
Wed Nov 12 15:56:11 CET 2014
Also look at the Frequently Asked Questions document that comes with your R installation:
7.10 How do I convert factors to numeric?
It may happen that when reading numeric data into R (usually, when reading in a file), they come in as factors. If f is such a factor object, you can use
to get the numbers back. More efficient, but harder to remember, is
In any case, do not call as.numeric() or their likes directly for the task at hand (as as.numeric() or unclass() give the internal codes).
David L Carlson
Department of Anthropology
Texas A&M University
College Station, TX 77840-4352
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Gerrit Eichner
Sent: Wednesday, November 12, 2014 8:06 AM
To: David Studer
Cc: r-help at r-project.org
Subject: Re: [R] factor levels > numeric values
take a look at the beginning of the "Warning" section of ?factor.
Hth -- Gerrit
> Hi everybody,
> I have another question (to which I could not find an answer in my r-books.
> I am sure, it's not a great issue, but I simply lack of a good idea how to
> solve this:
> One of my variables gets imported as a factor instead of a numeric variable.
> Now I have a...
> Factor w/ 63 levels "0","0.02","0.03",..: 1 NA NA 1 NA NA 1 1 53 10 ...
> How can I transform these factor levels into actual values?
> Thank you very much for any help!
> [[alternative HTML version deleted]]
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
R-help at r-project.org mailing list
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
More information about the R-help