[R] Problem with lattice bwplot

Luis Torgo ltorgo at liacc.up.pt
Fri Dec 13 15:38:03 CET 2002


I've come across the following error when using free scales with bwplot (I use 
a small example data set just to illustrate the problem):

> d <- data.frame(
x=c(34.4, 12.4, NA, 65.3, NA, 12.0, 45.0, 645.0, 644.0,323.0),
fac1=c('a','a','b','a','b','a','a','c','c','c'),
fac2=c('v2','v2','v1','v2','v2','v2','v1','v2','v1','v2')
)

# ok, although "x" has only NA values for fac1=='b'
> bwplot(fac2 ~ x | fac1,data=d)

# not ok, if I try to use different scales in the X axis
> bwplot(fac2 ~ x | fac1,data=d,scales=list(x="free"))
Error in pretty(x[is.finite(x)], ...) : x must be numeric

# I can go around the error with
> bwplot(fac2 ~ x | fac1,data=d[!is.na(d$x),],scales=list(x="free"))

The problem is that one of the panels has no data because 'x' has only NA 
values for that particular factor combination. This causes no problem with 
uniform scales, but generates that error when trying to guess the best scale 
for each panel. I think that it should be easy to add some test to the code 
obtaining the scales for each panel, to avoid the always unpleasant 
criptographic error messages ;-)

Thanks,
Luis Torgo

-- 
Luis Torgo
    FEP/LIACC, University of Porto   Phone : (+351) 22 607 88 30
    Machine Learning Group           Fax   : (+351) 22 600 36 54
    R. Campo Alegre, 823             email : ltorgo at liacc.up.pt
    4150 PORTO   -  PORTUGAL         WWW   : http://www.liacc.up.pt/~ltorgo




More information about the R-help mailing list