Hi all Im in desperate need of help. Im working with a grouped data object, called Orthodont in the nlme package in R, and am trying to fit various models (learning methods for my thesis), but one of the variables in the object is numeric, (age) and I need it to be a factor. Ive tried: as.factor(Orthodont$age) as.factor(as.character(Orthodont$age)) and various other things, but when I then check the class of the variables using sapply(Orthodont, data.class) I still get age as numeric Also, sex is a factor, but for the models Im fitting I need it to be coded as a binary variable with values (-1) for males and (+1) for females, and I dont know how to do this either. Please help-Im losing my mind .!
______________________________________________________________________________________________ UNIVERSITY OF CAPE TOWN This e-mail is subject to the UCT ICT policies and e-mail disclaimer published on our website at http://www.uct.ac.za/about/policies/emaildisclaimer/ or obtainable from +27 21 650 4500. This e-mail is intended only for the person(s) to whom it is addressed. If the e-mail has reached you in error, please notify the author. If you are not the intended recipient of the e-mail you may not use, disclose, copy, redirect or print the content. If this e-mail is not related to the business of UCT it is sent by the sender in the sender's individual capacity. _____________________________________________________________________________________________________ [[alternative HTML version deleted]]
______________________________________________ R-help@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.