-
Notifications
You must be signed in to change notification settings - Fork 0
/
tooth-growth-analysis.R
60 lines (49 loc) · 1.51 KB
/
tooth-growth-analysis.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# Loading the ToothGrowth dataset
data(ToothGrowth)
# Printing the structure of the dataset
str(ToothGrowth)
# Displaying the first few rows of the dataset
head(ToothGrowth)
# Basic statistics summary
summary(ToothGrowth)
# Boxplot for the variable 'len'
boxplot(ToothGrowth$len,
main="Boxplot of Length",
xlab="Supplement",
ylab="Length",
col=c("orange","green","blue"),
border="brown")
# Histogram for the variable 'len'
hist(ToothGrowth$len,
main="Histogram of Length",
xlab="Length",
ylab="Frequency",
col="skyblue")
# Density plot for the variable 'len'
plot(density(ToothGrowth$len),
main="Density Plot of Length",
xlab="Length",
ylab="Density",
col="red")
# Q-Q plot for checking normality of the variable 'len'
qqnorm(ToothGrowth$len,
main="Q-Q Plot of Length")
qqline(ToothGrowth$len)
# Correlation matrix for the dataset
cor_matrix <- cor(ToothGrowth[sapply(ToothGrowth, is.numeric)])
print(cor_matrix)
# Heatmap of the correlation matrix
library(ggplot2)
heatmap(cor_matrix,
main="Heatmap of Correlation Matrix",
xlab="Variables",
ylab="Variables",
col="green",
dendrogram="row",
trace="none")
# ANOVA for checking the effects of the variable 'supp' on the variable 'len'
anova_result <- aov(len ~ supp, data=ToothGrowth)
print(summary(anova_result))
# Tukey's HSD post-hoc test for multiple comparisons
tukey_result <- TukeyHSD(anova_result)
print(tukey_result)