Мы можем использовать with()
. Чтобы избежать пустых участков не выбранных видов, мы используем as.numeric()
, чтобы позволить boxplot()
различать виды по их фактору уровням , а не по меткам .
op <- par(mfrow=c(1, 2))
with(iris[iris$Species %in% "setosa", ],
boxplot(Sepal.Length ~ as.numeric(Species), xlab="Species"))
mtext("setosa", 1, 1)
with(iris[iris$Species %in% c("setosa", "virginica"), ],
boxplot(Sepal.Length ~ as.numeric(Species), xlab="Species", xaxt="n"))
mtext(c("setosa", "virginica"), 1, 1, at=1:2)
par(op)
Результат
