[R] mosaicplot(formula, data)--- bugged?
Michael Friendly
friendly at yorku.ca
Wed Jan 30 17:43:49 CET 2002
I have been tinkering with mosaicplot() and friends as a way
of learning R. As part of this, I've written a pair.table()
method for mosaic matrices, and would like to extend mosaicplot
to work with loglin and logln (MASS) objects. I'm using
R 1.4.0 on Win 98.
I've been trying to figure out the formula interface, and think
there's a bug, but not sure how to find it, yet alone fix it.
It seems to only work with independence models:
> data(HairEyeColor)
> mosaicplot(~ Hair + Eye + Sex, data=HairEyeColor)
> mosaicplot(~ Hair * Eye + Sex, data=HairEyeColor)
Error in aperm(a, perm, resize) : `perm' is of wrong length
here's a traceback:
> debug(mosaicplot)
> mosaicplot(~Hair + Eye + Sex + Hair:Eye, data=HairEyeColor)
debugging in: mosaicplot(~Hair + Eye + Sex + Hair:Eye, data =
HairEyeColor)
debug: UseMethod("mosaicplot")
Browse[1]>
Error in aperm(a, perm, resize) : `perm' is of wrong length
> traceback()
5: aperm(X, c(s.call, s.ans))
4: apply(x, margin, sum)
3: margin.table(data, match(varnames, names(dimnames(data))))
2: mosaicplot.formula(~Hair + Eye + Sex + Hair:Eye, data = HairEyeColor)
1: mosaicplot(~Hair + Eye + Sex + Hair:Eye, data = HairEyeColor)
>
but this works correctly:
> library(MASS)
> lm1 <- loglm(~Hair*Eye + Sex, HairEyeColor)
> lm1
Call:
loglm(formula = ~Hair * Eye + Sex, data = HairEyeColor)
Statistics:
X^2 df P(> X^2)
Likelihood Ratio 29.34982 15 0.01449443
Pearson 28.99286 15 0.01611871
>
Can anyone help?
--
Michael Friendly friendly at yorku.ca
York University http://www.math.yorku.ca/SCS/friendly.html
Psychology Department
4700 Keele Street Tel: (416) 736-5115 x66249
Toronto, Ontario, M3J 1P3 Fax: (416) 736-5814
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list