[R] Turn factors to numeric

joseph kambeitz jkamb at gmx.de
Thu Oct 9 12:59:36 CEST 2008


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 



More information about the R-help mailing list