On 2013-04-01 13:08, Matthew Lundberg wrote:
Note the edited subject line! I don't know why I typed it as it was before.
This says that as.numeric(as.character(f)) will work regardless of the
implementation, and I agree.
It's the recommendation to use as.numeric(levels(f))[f] that has me
wonde
Note the edited subject line! I don't know why I typed it as it was before.
This says that as.numeric(as.character(f)) will work regardless of the
implementation, and I agree.
It's the recommendation to use as.numeric(levels(f))[f] that has me
wondering about section 2.3.1 of the language defini
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
wrote:
>
> When used as an index, the factor is impl
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, A
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
as.numeric(as.chara
Hi Mathew,
In what way are they at odds?
On Mon, Apr 1, 2013 at 1:48 PM, 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 re
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 - secti
On May 26, 2010, at 4:05 AM, Ivan Calandra wrote:
What about (not tested because no sample data, and I'm definitely
unsure
of my lapply() solution):
lapply(data[2:13], FUN=as.character)
lapply(data[2:13], FUN=as.numeric)
?
That would not preserve any of the output since no assignments were
What about (not tested because no sample data, and I'm definitely unsure
of my lapply() solution):
lapply(data[2:13], FUN=as.character)
lapply(data[2:13], FUN=as.numeric)
?
data[2:13] should correspond to the 12 Month columns.
There might be a way to combine both lines but I don't think lapply
w
On Wed, May 26, 2010 at 1:13 PM, Ivan Calandra wrote:
> Hi,
>
> What about:
> as.numeric(as.character(data$State))
> ?
>
What I what is, I want to convert all the column excluding State to factor
to numeric in the data frame. So that I will send this data frame to
another function to total .
Hi,
What about:
as.numeric(as.character(data$State))
?
Ivan
Le 5/26/2010 09:32, Mohan L a écrit :
Dear All,
I have a data frame with State and 12 Months as column. I want to convert
all the 12 month column from factor to numeric.
any help will be greatly appreciated.
str(data)
'da
Dear All,
I have a data frame with State and 12 Months as column. I want to convert
all the 12 month column from factor to numeric.
any help will be greatly appreciated.
> str(data)
'data.frame':33 obs. of 9 variables:
$ State: Factor w/ 33 levels "Andaman and Nicobar Islands",..: 1 2 3
t; to "." in both datafile and code but the problem
>remains identical.
>Cheers!
>Jojje
>
>
>
>
>> Date: Thu, 24 Apr 2008 09:16:38 +0100> From:
>>[EMAIL PROTECTED]> To: [EMAIL PROTECTED]> CC:
>>r-help@r-project.org> Subject: Re: [R] Fa
t; > Date: Thu, 24 Apr 2008 09:16:38 +0100> From: [EMAIL PROTECTED]> To:
> [EMAIL PROTECTED]> CC: r-help@r-project.org> Subject: Re: [R] Factor
> to numeric> > The decimal point in R is always '.', never ','.> > On Thu, 24
> Apr 2008, Jojje A
s such.
Cheers!
Jojje
__
> Date: Thu, 24 Apr 2008 09:16:38 +0100
> From: [EMAIL PROTECTED]
> To: [EMAIL PROTECTED]
> CC: r-help@r-project.org
> Subject: Re: [R] Factor to numeric
>
> The decimal point in R is always '.', never ','.
>
> O
Hello!
Thanks!
I changed the "," to "." in both datafile and code but the problem remains
identical.
Cheers!
Jojje
> Date: Thu, 24 Apr 2008 09:16:38 +0100> From: [EMAIL PROTECTED]> To: [EMAIL
> PROTECTED]> CC: r-help@r-project.org> Subject: Re: [
The decimal point in R is always '.', never ','.
On Thu, 24 Apr 2008, Jojje Andersson wrote:
>
> Hello!
> I have a problem whith a data.frame. I want to make a subset where some of
> the variables have values within ceartain limits.
> The variables are proportions like 1,00, 0,54, 0,00 etc.
> I
Hello!
I have a problem whith a data.frame. I want to make a subset where some of the
variables have values within ceartain limits.
The variables are proportions like 1,00, 0,54, 0,00 etc.
I don't get it right as R take the variables for factors.
> ekobsub1 <- subset(ekob, PAP>0,25 & PAP<0,6
18 matches
Mail list logo