0
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

Ronak Shah
  • 377,200
  • 20
  • 156
  • 213
Matthew
  • 1
  • 2
  • It is not an error message but a warning. It does return something in `box2` but it is not identical to `box1`. – Ronak Shah Nov 20 '20 at 08:12
  • I find it admirable that you want to learn lattice but I wonder if there aren't better uses of your time. The package has been superseded by ggplot2 and is pretty much obsolete. – Roland Nov 20 '20 at 08:18

1 Answers1

1

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

Onyambu
  • 67,392
  • 3
  • 24
  • 53