Is there a way I could reproduce the box plots using the lattice package function bwplot()

117 Views Asked by At
par(mai = c(1, 1, 1, 1), omi = c(0, 0, 0, 0))
set.seed(591)
(xx1 <- rnorm(20, mean = 3, sd = 3.6))
(xx2 <- rpois(40, lambda = 3.5))
(xx3 <- rchisq(31, df = 5, ncp = 0))

box plot code using the R base package.

box1 <- boxplot(xx1, xx2, xx3, names = c("Group-1", "Group-2", "Group-3"), cex = 0.7)

trying to reproduce the same box plot using lattice package of R

box2 <- bwplot(xx1, xx2, xx3, names = c("Group-1", "Group-2",  "Group-3"), cex = 0.7)

I get the error code

In bwplot.numeric(xx1, xx2, xx3, cex = 0.7) : explicit data specification ignored

1

There are 1 best solutions below

2
Onyambu On

You should consider putting your data in a dataframe and use a formula as shown below:

bwplot(values~ind, stack(list(Group1=xx1, Group2=xx2, Group3=xx3)), cex=0.7)

enter image description here