Skip to content

sorting factors

2 messages · g, Thomas W Blackwell

g
#
Hi,

I've been trying to sort the values of the factors of contingency tables 
generated with xtabs. For example, I have a factor called "artic" with three 
possible values that I would like to order in a specific way -- but I'm not 
sure how to go about this.
Any help appreciated,
Gina
#
Try

artic <- factor(as.character(artic),
	levels=c("lowlip","dental","apex"),
	ordered=T)

Or use the function ordered() instead of factor(),
and omit the last argument above ("ordered=T").
See  help("ordered").  I'm not sure whether I even
need the  as.character()  syntax in there after
read.table(),  but it can't hurt.

This is just a guess at an answer, because I'm not
sure I understand quite what question you are asking.

-  tom blackwell  -  u michigan medical school  -  ann arbor  -
On Wed, 30 Apr 2003, g wrote: