R-FAQ 7.10:
http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-do-I-convert-factors-
to-numeric_003f
On Oct 9, 2008, at 6:59 AM, joseph kambeitz wrote:
> I am having some problems while trying to fit simple data.
> I aggregated some data using:
> data1 <- aggregate(data1$T2, list=(SOA=data1$SOA), mean)
>
> unfortunatly this coerces my variable SOA into a factor. Therefore
> when a afterwards try to fit a simple equation to my variable T2
> using a formula on SOA i get a error because SOA is a factor and
> that "*" is not meaningful for factors...
>
> nls(T2 ~ a + b*SOA, start=list(a=1,b=1), data=data1, trace=TRUE)
>
> In fact SOA is a numeric variable (in my experiments it is the time
> that passed!) so i would like to re-coerce it into a numeric
> variable to do the fit or to find a method to do the fit even
> though SOA is a factor. Thanks a lot for your help!
>
> Best
> Jokel
> --
> Ist Ihr Browser Vista-kompatibel? Jetzt die neuesten
>
> ______________________________________________
> 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.
Haris Skiadas
Department of Mathematics and Computer Science
Hanover College