DS Labs Porject

Quarto

Load libraries

library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.1.4     ✔ readr     2.1.5
✔ forcats   1.0.0     ✔ stringr   1.5.1
✔ ggplot2   3.5.1     ✔ tibble    3.2.1
✔ lubridate 1.9.4     ✔ tidyr     1.3.1
✔ purrr     1.0.4     
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(dslabs) 
library(plotly)

Attaching package: 'plotly'

The following object is masked from 'package:ggplot2':

    last_plot

The following object is masked from 'package:stats':

    filter

The following object is masked from 'package:graphics':

    layout
data("mice_weigths")

filter for just generation 8

mice <- mice_weights |>
  filter(gen == 8)

Create the plot

p<- ggplot(data=mice_weights, aes(x=body_weight, y=percent_fat, color=sex))+
  geom_point()+
  geom_smooth()+
  scale_color_brewer(palette = "Set1")+
  theme_minimal(base_size = 14)+
  labs(title="Mice Weight and Percent Body Fat by Sex", 
     x="Weight (ounces)", 
     y="Percent Body Fat")
ggplotly(p)
`geom_smooth()` using method = 'loess' and formula = 'y ~ x'
Warning: Removed 4 rows containing non-finite outside the scale range
(`stat_smooth()`).

Essay

I used the mouse weights dataset, and created a dot plot with a smoothed line. The graph compares the mice’s wight in grams with their percent body fat, and is separated by male and female mice. I first tried creating the graph by filtering for a specific generation, but I decided to use the whole dataset because I enjoyed being able to see the bigger picture. The female mice clearly present a trend of higher body fat percentages, and an average higher weight than the males. There is also a direct relationship between an increase in body fat, and an increase in weight.