Thomas Levine
2010-Feb-28 03:01 UTC
[R] Error in tapply when reordering levels of a factor
I have this> grades$grade... [4009] A B A- A- A- B+ A A- B+ B A B B B A A- A A- A- B+ A- A A B+ [4033] A- A- A- A A- B A A A- A Levels: A A- A+ B B- B+ C C+ I want to change the order of the levels> reorder(grades$grade,c('A+','A','A-','B+','B','B-','C+','C'))Error in tapply(X, x, FUN, ...) : arguments must have same length What am I doing wrong? Thanks Tom
David Winsemius
2010-Feb-28 03:07 UTC
[R] Error in tapply when reordering levels of a factor
On Feb 27, 2010, at 10:01 PM, Thomas Levine wrote:> I have this > >> grades$grade > ... > [4009] A B A- A- A- B+ A A- B+ B A B B B A A- A A- A- B+ > A- A A B+ > [4033] A- A- A- A A- B A A A- A > Levels: A A- A+ B B- B+ C C+ > > I want to change the order of the levels > >> reorder(grades$grade,)Try instead: grades$grades <- factor(grades$grades, levels= c('A+','A','A-','B+','B','B-','C+','C')> Error in tapply(X, x, FUN, ...) : arguments must have same length > > What am I doing wrong? Thanks > > Tom > > ______________________________________________ > 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.David Winsemius, MD Heritage Laboratories West Hartford, CT