[R] bwplot does something weird with Hmisc library attached

Petr Pikal petr.pikal at precheza.cz
Wed Jul 16 17:13:57 CEST 2003


Dear all

I would like to ask you about possible bug in using bwplot (from lattice) together 
with Hmisc library attached. I found it in my actual data, but here is a toy 
example. It appears only when some levels are missing.

library(lattice)
library(Hmisc)

# preparing data
x1<-rnorm(10,5,1)
x2<-rnorm(10,5,5)
x3<-rnorm(10,1,1)
x4<-rnorm(10,1,5)
x<-c(x1,x2,x3,x4)
x<-c(x,x+5)
f2<-as.factor(rep(c("a","b","a","b"),c(20,20,20,20)))
f3<-as.factor(rep(rep(c("c","d"),each=10),4))
f1<-as.factor(rep(c(1,2),c(40,40)))
data<-data.frame(x,f1,f2,f3)
rm(x,f1,f2,f3)
attach(data)

# 1st plot
bwplot(f1~x|f2)

# 2 is bigger than 1 **OK**

# 2nd plot
bwplot(f1~x|f2*f3)

# again 2 is bigger than 1 **OK**

# removing some levels
detach("data")
data<-data[-c(1:10,21:30),]
attach(data)

# 3rd plot
bwplot(f1~x|f2)

# 2 is bigger than 1 **OK**

# 4th plot
bwplot(f1~x|f2*f3)

### OOOPS  1 is bigger than 2 ***FALSE*** 

after detaching Hmisc 
detach("package:Hmisc")

#5th plot
bwplot(f1~x|f2*f3)

# again 2 is bigger than 1 **OK**

The levels for factor f1 are in the OOOPS case reversed, maybe it has something 
to do with factor redefinition as stated when attaching Hmisc library.

Is it a bug or am I doing something wrong?

R 1.7.1 WNT

Package: Hmisc
Version: 1.6-1
Date: 2003-06-21

Package: lattice
Version: 0.7-14
Date: 2003/06/07

Thank you for any response.

Petr Pikal
petr.pikal at precheza.cz
p.pik at volny.cz




More information about the R-help mailing list