Hi, I have imported some data to R from stata and my factor variables have an Indeterminate level which I don't really want. For example the variable sex has the levels Male, Female and Indeterminate. There are no 'Indeterminate' values in the data. Can somebody tell me how to get rid of this level as it restricting my cox ph model. Thanks Neil
Try:> sex <- factor(sample(c("M", "F"), 10, replace=TRUE), levels=c("M", "F","I"))> sex[1] F F M F F F M M M F Levels: M F I> sex2 <- sex[, drop=TRUE] > sex2[1] F F M F F F M M M F Levels: M F HTH, Andy> From: Neil Leonard > > Hi, > > I have imported some data to R from stata and my factor > variables have > an Indeterminate level which I don't really want. For example the > variable sex has the levels Male, Female and Indeterminate. There are > no 'Indeterminate' values in the data. Can somebody tell me > how to get > rid of this level as it restricting my cox ph model. > > Thanks > Neil > > ______________________________________________ > R-help at 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 > >
Hi Neil, you could try sex <- sex[,drop=TRUE] I hope it helps. Best, Dimitris ---- Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/16/396887 Fax: +32/16/337015 Web: http://www.med.kuleuven.ac.be/biostat/ http://www.student.kuleuven.ac.be/~m0390867/dimitris.htm ----- Original Message ----- From: "Neil Leonard" <nleonard at tartarus.uwa.edu.au> To: "r help" <r-help at stat.math.ethz.ch> Sent: Thursday, October 07, 2004 4:13 PM Subject: [R] Remove Indeterminate Level> Hi, > > I have imported some data to R from stata and my factor variables > have an Indeterminate level which I don't really want. For example > the variable sex has the levels Male, Female and Indeterminate. > There are no 'Indeterminate' values in the data. Can somebody tell > me how to get rid of this level as it restricting my cox ph model. > > Thanks > Neil > > ______________________________________________ > R-help at 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 >
On Thu, 7 Oct 2004, Neil Leonard wrote:> Hi, > > I have imported some data to R from stata and my factor variables have an > Indeterminate level which I don't really want. For example the variable sex > has the levels Male, Female and Indeterminate. There are no 'Indeterminate' > values in the data. Can somebody tell me how to get rid of this level as it > restricting my cox ph model. >Two ways to do this are in the Examples section of help(factor) -thomas