[R] How to avoid sort of x values in dotplot?

Bernd Weiss bernd.weiss at uni-koeln.de
Tue Feb 20 06:25:45 CET 2007


Am 19 Feb 2007 um 20:28 hat Rene Braeckman geschrieben:

From:           	"Rene Braeckman" <RMan54 at cox.net>
To:             	<r-help at stat.math.ethz.ch>
Date sent:      	Mon, 19 Feb 2007 20:28:01 -0800
Subject:        	[R] How to avoid sort of x values in dotplot?

> I am trying to avoid that dotplot sorts my x-values. They are in the
> correct order in the data.frame and the connections between the x-y
> values follows this order, but the placement of the x-values on the
> x-axis is re-ordered. In the following example, the order should be
> "d1", "d8" and "d15". However, this script places "d8" at the highest
> x position. Any help is appreciated.
> 
> Subj <- rep(1:4,each=3)
> Time <- rep(c("d1","d8","d15"),4)
> Conc <- 1:12
> df <- data.frame(Subj,Time,Conc)
> dotplot(Conc ~ Time | Subj,
>        data = df,
>        layout = c(2,2),
>        type="b")
> 

library(lattice)
Subj <- rep(1:4,each=3)
Time <- rep(c("d1","d8","d15"),4)
Conc <- 1:12
df <- data.frame(Subj,Time,Conc)
df$Time <- factor(df$Time,levels=df$Time)
dotplot(Conc ~ Time | Subj,
       data = df,
       layout = c(2,2),
       type="b")

HTH,

Bernd



More information about the R-help mailing list