DSLabs Datasets

Author

E Choi

Load packages

library(ggplot2)
library("dslabs")
data(package="dslabs")
list.files(system.file("script", package = "dslabs"))
 [1] "make-admissions.R"                   
 [2] "make-brca.R"                         
 [3] "make-brexit_polls.R"                 
 [4] "make-calificaciones.R"               
 [5] "make-death_prob.R"                   
 [6] "make-divorce_margarine.R"            
 [7] "make-gapminder-rdas.R"               
 [8] "make-greenhouse_gases.R"             
 [9] "make-historic_co2.R"                 
[10] "make-mice_weights.R"                 
[11] "make-mnist_127.R"                    
[12] "make-mnist_27.R"                     
[13] "make-movielens.R"                    
[14] "make-murders-rda.R"                  
[15] "make-na_example-rda.R"               
[16] "make-nyc_regents_scores.R"           
[17] "make-olive.R"                        
[18] "make-outlier_example.R"              
[19] "make-polls_2008.R"                   
[20] "make-polls_us_election_2016.R"       
[21] "make-pr_death_counts.R"              
[22] "make-reported_heights-rda.R"         
[23] "make-research_funding_rates.R"       
[24] "make-results_us_election_2012.R"     
[25] "make-stars.R"                        
[26] "make-temp_carbon.R"                  
[27] "make-tissue-gene-expression.R"       
[28] "make-trump_tweets.R"                 
[29] "make-weekly_us_contagious_diseases.R"
[30] "save-gapminder-example-csv.R"        
data("mice_weights")
Warning in data("mice_weights"): data set 'mice_weights' not found
weights <- mice_weights
# Create a boxplot of weight by diet
ggplot(mice_weights, aes(x = diet, y = body_weight, color = sex)) +  # diet to x-axis, weight to y-axis, colored by sex
  geom_boxplot() +  # add boxplot layer 
  labs(  # add labels and title
    x = "Diet Type",  # label for x-axis
    y = "Weight (grams)",  # label for y-axis
    title = "Mouse Weights by Diet",  # title for the plot
    color = "Gender" #legend label
  ) +
  theme_bw(base_size = 14)   # simple theme

Description

In this visualization, I used the mice_weights dataset from the dslabs package, which contains many variables. I used weight measurements for mice subjected to different diets and separated by sex. The boxplot shows the distribution of weights for each diet type, while the colors represent the sex of the mice. From the graph, it is apparent that gf diets produce higher average weights than others, and males generally tend to weigh more than females across the same diet. Additionally, the spread of weights varies by diet, indicating that certain diets may lead to more variable growth outcomes. Outliers are showing individual mice whose weights were unusually high or low compared to their group. This visualization helps to quickly compare the effects of diet and sex on mouse weights and could guide further research into diet weight changes.