These two seem to be at odds. Is this the case?
From help(factor) - section Warning:
To transform a factor f to approximately its original numeric values,
as.numeric(levels(f))[f] is recommended and slightly more efficient than
as.numeric(as.character(f)).
From the language definition -
Hi Mathew,
In what way are they at odds?
On Mon, Apr 1, 2013 at 1:48 PM, Matthew Lundberg
matthew.k.lundb...@gmail.com wrote:
These two seem to be at odds. Is this the case?
From help(factor) - section Warning:
To transform a factor f to approximately its original numeric values,
On 2013-04-01 10:48, Matthew Lundberg wrote:
These two seem to be at odds. Is this the case?
From help(factor) - section Warning:
To transform a factor f to approximately its original numeric values,
as.numeric(levels(f))[f] is recommended and slightly more efficient than
When used as an index, the factor is implicitly converted to integer. In
the expression as.numeric(levels(f))[f], the vector as.numeric(levels(f))
is indexed by as.integer(f).
This appears to rely on the current implementation, as mentioned in section
2.3.1 of the language definition.
On Mon,
Yup. Note also:
as.character.factor
function (x, ...)
levels(x)[x]
But of course this is OK, since this can change if the implementation
does. Which is the whole point, of course.
-- Bert
On Mon, Apr 1, 2013 at 12:16 PM, Matthew Lundberg
matthew.k.lundb...@gmail.com wrote:
When used as an
5 matches
Mail list logo