set.seed(42)
# Sinh dữ liệu: mean = 30, sd = 10
data <- rnorm(350, mean = 30, sd = 10)
shapiro_test <- shapiro.test(data)
shapiro_test
##
## Shapiro-Wilk normality test
##
## data: data
## W = 0.99773, p-value = 0.9187
if (shapiro_test$p.value > 0.05) {
cat("Kết luận: Dữ liệu có phân phối chuẩn (không bác bỏ H0)\n")
} else {
cat("Kết luận: Dữ liệu không có phân phối chuẩn (bác bỏ H0)\n")
}
## Kết luận: Dữ liệu có phân phối chuẩn (không bác bỏ H0)
data(iris)
head(iris)
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 1 5.1 3.5 1.4 0.2 setosa
## 2 4.9 3.0 1.4 0.2 setosa
## 3 4.7 3.2 1.3 0.2 setosa
## 4 4.6 3.1 1.5 0.2 setosa
## 5 5.0 3.6 1.4 0.2 setosa
## 6 5.4 3.9 1.7 0.4 setosa
min_values <- sapply(iris[, 1:4], min)
max_values <- sapply(iris[, 1:4], max)
result <- data.frame(
Min = min_values,
Max = max_values
)
result
## Min Max
## Sepal.Length 4.3 7.9
## Sepal.Width 2.0 4.4
## Petal.Length 1.0 6.9
## Petal.Width 0.1 2.5
hist(
iris$Sepal.Length,
breaks = 15,
main = "Histogram of Sepal Length",
xlab = "Sepal Length",
col = "lightblue",
border = "black"
)
