[R] ordering in dotplot

Chuck Cleland ccleland at optonline.net
Mon Feb 2 11:23:38 CET 2004


Luca De Benedictis wrote:
> the dataset I am using (data.it) is organized as follows
> ...    ...    ...    ...
> and plotting it using dotplot, I specified the script as:
> 
> library(lattice)
> attach(data.ita)
> dotplot(reg~stp | partner, data=data.ita, groups=btp,
>            xlab=list("Data - 
> it",cex=1.5),col=c("black","red"),aspect=0.3,as.table=TRUE,xlim=c(-1,1))
> detach(data.ita)
> 
> In the resulting plot the variable "reg" is ordered alphabetically. 
> Instead, I would like the variable to be plotted in the following order: 
> "s", "s-f", "d", "d-f".

Make that an ordered factor as follows:

data.it$reg <- ordered(data.it$reg, levels=c("s", "s-f", "d", "d-f"))

hope this helps,

Chuck Cleland

-- 
Chuck Cleland, Ph.D.
NDRI, Inc.
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 452-1424 (M, W, F)
fax: (917) 438-0894




More information about the R-help mailing list