2025-10-19

R Markdown

This is an R Markdown presentation. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document.

Penguins Dataset

  • I used penguin data.
## # A tibble: 3 × 8
##   species island    bill_length_mm bill_depth_mm flipper_length_mm body_mass_g
##   <fct>   <fct>              <dbl>         <dbl>             <int>       <int>
## 1 Adelie  Torgersen           39.1          18.7               181        3750
## 2 Adelie  Torgersen           39.5          17.4               186        3800
## 3 Adelie  Torgersen           40.3          18                 195        3250
## # ℹ 2 more variables: sex <fct>, year <int>

plotly

  • The joint distribution of bill length and bill depth seems to have the same shape over the years.
  • However, it seems that the distribution was the widest in 2007 and decreased from there.

math - linear regression

  • If the penguin had a larger mass, would it need larger (and theoretically, more powerful) flippers to propel itself in the water?
  • equation of a line: \[ \text{flipper length} = m + b \cdot \text{body mass} \]
  • m = slope, b = intercept

adding a lin reg line to a graph

reg1 = lm(flipper_length_mm ~ body_mass_g, data = penguins)
plot(penguins$body_mass_g, penguins$flipper_length_mm, pch = 20, col = "orange", xlab = "body mass (g)", ylab = "flipper length (mm)", main = 'flipper length vs body mass of penguins')
abline(reg1)

ggplot 1

  • by species

ggplot 2

  • by sex

math - mean

  • equation for mean: \[ \text{mean bill length} = \sum \text{bill length} \div \text {number of penguins} \]

pie chart

  • How many penguins in the data came from each island?