david.barron@said-business-school.oxford.ac.uk
2003-Apr-11 19:11 UTC
[Rd] lattice bug? (PR#2765)
I've been experimenting with the lattice graphics in chapter 3 of MASS. The code to produce figure 3.14 is: data(crabs) library(mva) lcrabs.pc <- predict(princomp(log(crabs[,4:8]))) crabs.grp <- c("B", "b", "O", "o")[rep(1:4, rep(50,4))] splom( ~lcrabs.pc[, 1:3], groups = crabs.grp, panel = panel.superpose, key = list(text = list(c("Blue male", "Blue female", "Orange Male", "Orange female")), points = Rows(trellis.par.get("superpose.symbol"), 1:4), columns = 4) ) This fails with the error: Error in 1:ncol(x) : NA/NaN argument I traced this to the line in the splom function: for (j in 1:ncol(x)) id.na <- id.na | is.na(x[, j]) but the root of the problem actually seems to be earlier, when latticParseFormula is called. form <- if (inherits(formula, "formula")) latticeParseFormula(formula, data) x <- as.data.frame(form$right) This seems not to work properly if data=parent.frame(). Should it? Apologies if this is something known, or if I'm doing something wrong! I'm using R 1.6.2 under Windows 2000 Pro and lattice Version: 0.7-1 Date: 2003/03/15. Thanks, David ==================================================David Barron Jesus College Oxford OX1 3DW 01865 279684
Works perfectly with the current lattice -- 0.7-4. It's already been reported and fixed. On Fri, 11 Apr 2003 david.barron@said-business-school.oxford.ac.uk wrote:> I've been experimenting with the lattice graphics in chapter 3 of MASS. The > code to produce figure 3.14 is: > > data(crabs) > library(mva) > lcrabs.pc <- predict(princomp(log(crabs[,4:8]))) > crabs.grp <- c("B", "b", "O", "o")[rep(1:4, rep(50,4))] > splom( ~lcrabs.pc[, 1:3], groups = crabs.grp, > panel = panel.superpose, > key = list(text = list(c("Blue male", "Blue female", > "Orange Male", "Orange female")), > points = Rows(trellis.par.get("superpose.symbol"), 1:4), > columns = 4) > ) > > This fails with the error: Error in 1:ncol(x) : NA/NaN argument > > I traced this to the line in the splom function: > > for (j in 1:ncol(x)) id.na <- id.na | is.na(x[, j]) > > but the root of the problem actually seems to be earlier, when > latticParseFormula is called. > > form <- if (inherits(formula, "formula")) > latticeParseFormula(formula, data) > x <- as.data.frame(form$right) > > This seems not to work properly if data=parent.frame(). Should it? > Apologies if this is something known, or if I'm doing something wrong! > > I'm using R 1.6.2 under Windows 2000 Pro and lattice Version: 0.7-1 Date: > 2003/03/15. > > Thanks, > David > > ==================================================> David Barron > Jesus College > Oxford OX1 3DW > 01865 279684 > > ______________________________________________ > R-devel@stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-devel >-- Brian D. Ripley, ripley@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595