The dataset contains 71 chicks in six feed groups. Their weights were measured after six weeks.
table(chickwts$feed)
## ## casein horsebean linseed meatmeal soybean sunflower ## 12 10 12 11 14 12
2026-10-18
The dataset contains 71 chicks in six feed groups. Their weights were measured after six weeks.
table(chickwts$feed)
## ## casein horsebean linseed meatmeal soybean sunflower ## 12 10 12 11 14 12
\[ \text{Group proportion} = \frac{\text{Number of chicks in the group}} {\text{Total Number of Chicks}} \] This mathematical formula can better determine the proportion of chicks fed each type of feed in the total number.
\[ \text{Average weight} = \frac{\text{Total weight of chicks in the group}} {\text{Number of chicks in the group}} \] This mathematical formula allows for average comparisons even when quantities are unequal, providing a better understanding of which feed produces chicks that grow larger.
group_counts <- table(chickwts$feed) group_proportion <- group_counts / nrow(chickwts) group_proportion
## ## casein horsebean linseed meatmeal soybean sunflower ## 0.1690141 0.1408451 0.1690141 0.1549296 0.1971831 0.1690141
average_weight <- tapply(chickwts$weight, chickwts$feed, mean) average_weight
## casein horsebean linseed meatmeal soybean sunflower ## 323.5833 160.2000 218.7500 276.9091 246.4286 328.9167
ggplot(chickwts, aes(x = feed)) +
geom_bar(fill = "#FFC627") +
labs(
x = "Feed froup",
y = "Number of Chicks"
)
This data shows that the number of chicks differs between groups; the Soybean feed group has the most chicks, while the Horsebean feed group has the fewest.
ggplot(chickwts) +
geom_density(aes(x = weight, fill = feed), alpha = 0.5) +
labs(
x = "Weight",
y = "Density",
fill = "Feed Group"
)
This data presents the body weight density of different feed groups. It is clear that the sunflower group has the most individuals with a body weight between 300-380 kg, while the horsebean group has the most individuals with a body weight between 100-200 kg.
average_weight <- tapply(chickwts$weight, chickwts$feed, mean)
barplot(average_weight,
xlab = "Feed Group",
ylab = "Average Weight",
col = "black")
In this data, the average weight of the sunflower and casein groups is very high, while the average weight of the horsebean group is the lowest.
p <- ggplot(chickwts, aes(x = feed, y =weight)) + geom_jitter(width = 0.2, height = 0) + labs(x = "Feed Group", y = "Weight") ggplotly(p)
Statistics helps us extract the data we need from complex datasets and generate graphical visualizations.
Different data visualization methods have different uses. Some of the most commonly used graphs include: box plots, suitable for displaying distributions, medians, and outliers; bar charts, suitable for comparing data with uniform categories, quickly showing the differences between numerical values in different categories; density plots, suitable for visually displaying numerical distributions;
Finally, interactive visualizations, which transform data into graphs that allow users to hover over different points to view specific values, and intuitively compare and select the data they need, observing its location and specific values. However, direct searching within these graphs is not possible.