Davor Josipovic
Davor Josipovic

Reputation: 5504

lattice::bwplot and groups parameter

Here is a code example (based on random data):

lattice::bwplot(runif(1000) ~ cut(runif(1000), c(0,0.3,0.6,1)) | as.factor(c(1,2,3)), 
                groups = sample(1:2, 1000, replace = TRUE), auto.key = TRUE)

The output:

enter image description here

I am expecting to get 6 boxplots in each panel due to groups, but I only get 3. At the top is the legend: one sees two colors representing 2 groups but you don't see these in the pannels.

How can I get 6 boxplots in each panel, one for each interval and for each group in the correct color?

Upvotes: 1

Views: 861

Answers (1)

Johan Larsson
Johan Larsson

Reputation: 3694

The groups argument in bwplot() doesn't do much other than affect the key unfortunately. I wrote a modified bwplot() in my tactile package.

Try:

tactile::bwplot2(runif(1000) ~ cut(runif(1000), c(0,0.3,0.6,1)) | as.factor(c(1,2,3)), 
                 groups = sample(1:2, 1000, replace = TRUE), auto.key = TRUE)

enter image description here

Upvotes: 4

Related Questions