-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpenguins_analysis.qmd
More file actions
41 lines (37 loc) · 1.07 KB
/
penguins_analysis.qmd
File metadata and controls
41 lines (37 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# Loading packages
```{r}
library(tidyverse)
library(palmerpenguins)
```
```{r}
test_variable <- 5
penguins_df <- penguins
```
```{r}
cleaned_penguins_df <- penguins_df |>
mutate(age = 2025 - year)
# |>
#filter(flipper_length_mm > 200) |>
# group_by(species) |>
# summarize(num_penguins = n(), mean_body_mass = mean(body_mass_g, na.rm = TRUE))
```
```{r}
mean_bill_length <- cleaned_penguins_df |> group_by(species) |> summarize(num_penguins = n(), mean_bill_length = mean(bill_length_mm, na.rm = TRUE))
mean_bill_length
```
```{r}
penguins_df |>
count(species, island)
prop_species_df <- penguins_df |> group_by(species, island) |>
mutate(n_per_species_and_island = n()) |>
group_by(island) |>
mutate(n_per_island = n(), prop_species = n_per_species_and_island / n_per_island)
```
```{r}
ggplot(data=penguins_df,
mapping = aes(x=flipper_length_mm, y=bill_length_mm)) +
geom_point(size=4, alpha=0.5) +
labs(x="Flipper length (mm)", y="Bill Length (mm)", title="Correlation between flipper length and bill length") +
geom_smooth() +
theme_classic()
```