2026-10-18

Chickwts Data

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

Numbers of Chicks in Each Feed Group

\[ \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.

Comparing the effects of different feeds on chick weight changes over the same time period

\[ \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.

R show Group proportion and Average weight

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

Number of Chicks by Feed Groups

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.

Distribution of Chick Weights

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 by Feed Group

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.

Show INdividual Chick Weights

p <- ggplot(chickwts, aes(x = feed, y =weight)) + 
  geom_jitter(width = 0.2, height = 0) + 
  labs(x = "Feed Group", y = "Weight")
ggplotly(p)

What did we Learn?

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.