data(iris)
ket_qua <- aggregate(
Sepal.Width ~ Species,
data = iris,
FUN = function(x) c(
Nho_nhat = min(x),
Lon_nhat = max(x),
Do_lech_chuan = sd(x)
)
)
ket_qua
## Species Sepal.Width.Nho_nhat Sepal.Width.Lon_nhat
## 1 setosa 2.3000000 4.4000000
## 2 versicolor 2.0000000 3.4000000
## 3 virginica 2.2000000 3.8000000
## Sepal.Width.Do_lech_chuan
## 1 0.3790644
## 2 0.3137983
## 3 0.3224966
library(ggplot2)
ggplot(iris, aes(x = Species, y = Sepal.Length)) +
geom_boxplot(fill = "lightblue") +
labs(
title = "Boxplot Sepal.Length theo Species",
x = "Species",
y = "Sepal.Length"
) +
theme_minimal()
