[R] sorting factors

g gina.joue at ucd.ie
Wed Apr 30 18:33:00 CEST 2003


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.

> test <- read.table("test.tab",header=TRUE,sep="\t")
> artic = factor(artic,levels=c("lowlip","dental","apex"))
> test.frame <- as.data.frame(test)
> test.xtabs <- xtabs(freq ~ artic + var, test.frame)
> mosaicplot(test.xtabs,shade=TRUE)

Any help appreciated,
Gina



More information about the R-help mailing list