[R] how to plot numeric variable against several categories with lattice bwplot?
Luigi Marongiu
m@rong|u@|u|g| @end|ng |rom gm@||@com
Thu Jan 13 20:38:04 CET 2022
Hello,
I have a numerical variable (x) and a series of categories. I would
like to make a box plot of x against each of the categories. How can I
arrange the data so that I can accomplish it with lattice?
At the moment I got this:
```
df = data.frame(x = c(rep(1,5), rep(2,5), rep(3,5)),
y = rnorm(15),
f1 = rep(letters[1:5],3),
f2 = rep(letters[7:9],5),
f3 = c(rep(LETTERS[10:12],4), LETTERS[10:12]))
df$x = factor(df$x)
df$f1 = factor(df$f1)
df$f2 = factor(df$f2)
df$f3 = factor(df$f3)
library(lattice)
bwplot(y ~ x, data = df, auto.key = TRUE )
```
Also, is it possible to have the wishers in solid line?
Thank you
More information about the R-help
mailing list