Re: [R] factor to numeric (no subject)

From: Petr Pikal <petr.pikal_at_precheza.cz>
Date: Tue 12 Sep 2006 - 13:04:46 GMT


Hi

all culumns which are used for discrimination (in your case 3) are factor. If you want to change them to numeric you has to use

as.numeric(as.character(x[,3]))

I believe it is in FAQ.

HTH
Petr

Please use sensible subject.

On 12 Sep 2006 at 14:49, Anders Eklund wrote:

Date sent:      	Tue, 12 Sep 2006 14:49:18 +0200 (CEST)
From:           	"Anders Eklund" <aeklund@kth.se>
To:             	"r-help@lists.R-project.org" <r-help@stat.math.ethz.ch>
Subject:        	[R] (no subject)

> Hi,
>
> I have a problem with aggregate.
>
> x <- aggregate(t1,list(t2,t3,t4), mean)
>
> z<-x[,3]
>
> I want z to be a vector but it is a factor.
>
> I've tried to use as.vector(z,mode="numeric") but then the numbers get
> scrambeled.
>
> Any help is appriciated
>
> /anders
>
> ______________________________________________
> R-help@stat.math.ethz.ch 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.

Petr Pikal
petr.pikal@precheza.cz



R-help@stat.math.ethz.ch 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. Received on Tue Sep 12 23:09:21 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Tue 12 Sep 2006 - 13:30:04 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.