[R] Superpose two QQ-plots (gamma distribution) with lattice function qqmath()

Yvonnick Noel yvonnick.noel at uhb.fr
Fri Jun 21 16:55:06 CEST 2013


Hello,

I am trying to superpose on a single panel two QQ plots with the lattice 
qqmath function.

Here is a reproducible example of the problem I am facing:

# Generate data
shape = 8
rate = c(rep(1/4,100),rep(1/3,100))
x = rgamma(200,shape,rate)
groups = gl(2,100,200,labels=LETTERS[1:2])

# Plot
qqmath(~x,groups=groups,panel = "panel.superpose",
distribution = function(x) qgamma(x,shape,rate),
panel.groups = function(x,subscripts,...) {
	panel.qqmath(x,shape=shape,rate=rate[subscripts],...)
	panel.qqmathline(x,shape=shape,rate=rate[subscripts],...)
})

Both data series seem to be reproduced twice, somewhat rescaled.

I don't understand what this mean.

What am I doing wrong?

Thanks a lot for your help,

Yvonnick Noel
University of Brittany, Rennes
Dpt. of Psychology
France



More information about the R-help mailing list