This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| penguins_wide <- penguins_long %>% | |
| tidyr::pivot_wider(names_from = c("part", "measure", "unit"), # pivot these columns | |
| values_from = "value", # take the values from here | |
| names_sep = "_") # combine col names using an underscore | |
| penguins_wide | |
| # A tibble: 344 x 9 | |
| # Groups: species, island, sex, year [35] | |
| species island sex year penguinid bill_length_mm bill_depth_mm flipper_length_mm body_mass_g |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| penguins_long <- penguins_id %>% | |
| tidyr::pivot_longer(contains("_"), # break out the measurement cols | |
| names_to = c("part", "measure", "unit"), # break them into these three columns | |
| names_sep = "_") # use the underscore to separate | |
| penguins_long | |
| # A tibble: 1,376 x 9 | |
| # Groups: species, island, sex, year [35] | |
| species island sex year penguinid part measure unit value |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| penguins_id <- penguins %>% | |
| dplyr::group_by(species, island, sex, year) %>% | |
| dplyr::mutate(penguinid = row_number(), .before = contains("_")) | |
| penguins_id | |
| # A tibble: 344 x 9 | |
| # Groups: species, island, sex, year [35] | |
| species island sex year penguinid bill_length_mm bill_depth_mm flipper_length_mm body_mass_g | |
| <fct> <fct> <fct> <int> <int> <dbl> <dbl> <int> <int> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| penguins <- penguins %>% | |
| dplyr::relocate(contains("_"), .after = year) | |
| penguins | |
| # A tibble: 344 x 8 | |
| species island sex year bill_length_mm bill_depth_mm flipper_length_mm body_mass_g | |
| <fct> <fct> <fct> <int> <dbl> <dbl> <int> <int> | |
| 1 Adelie Torgersen male 2007 39.1 18.7 181 3750 | |
| 2 Adelie Torgersen female 2007 39.5 17.4 186 3800 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| penguins %>% | |
| dplyr::select(!contains("_"), starts_with("bill")) | |
| # A tibble: 344 x 6 | |
| species island sex year bill_length_mm bill_depth_mm | |
| <fct> <fct> <fct> <int> <dbl> <dbl> | |
| 1 Adelie Torgersen male 2007 39.1 18.7 | |
| 2 Adelie Torgersen female 2007 39.5 17.4 | |
| 3 Adelie Torgersen female 2007 40.3 18 | |
| 4 Adelie Torgersen NA 2007 NA NA |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(tidyverse) | |
| library(palmerpenguins) | |
| penguins | |
| # A tibble: 344 x 8 | |
| species island bill_length_mm bill_depth_mm flipper_length_mm body_mass_g sex year | |
| <fct> <fct> <dbl> <dbl> <int> <int> <fct> <int> | |
| 1 Adelie Torgersen 39.1 18.7 181 3750 male 2007 | |
| 2 Adelie Torgersen 39.5 17.4 186 3800 female 2007 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(tidyverse) | |
| library(palmerpenguins) | |
| penguins | |
| # A tibble: 344 x 8 | |
| species island bill_length_mm bill_depth_mm flipper_length_mm body_mass_g sex year | |
| <fct> <fct> <dbl> <dbl> <int> <int> <fct> <int> | |
| 1 Adelie Torgersen 39.1 18.7 181 3750 male 2007 | |
| 2 Adelie Torgersen 39.5 17.4 186 3800 female 2007 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Package: isawesome | |
| Type: Package | |
| Title: Tells people they are awesome | |
| Version: 0.1.0 | |
| Author: c( | |
| person(given = "Jiena", | |
| family = "McLellan", | |
| role = c("aut", "cre"), | |
| email = "jienagu90@gmail.com") | |
| person(given = "Keith", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (plots$plotcol[1]$scatter | plots$plotcol[2]$scatter | plots$plotcol[3]$scatter) / | |
| (plots$boxcol[1]$box | plots$boxcol[2]$box | plots$boxcol[3]$box) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(patchwork) | |
| scatter_plot <- function(df, xvar, yvar) { | |
| ggplot(df) + | |
| geom_point(aes(x = {{xvar}}, y = {{yvar}})) | |
| } | |
| box_plot <- function(df, xvar, yvar, groupvar) { | |
| ggplot(df) + | |
| geom_boxplot(aes(x = {{xvar}}, y = {{yvar}}, group = {{groupvar}})) |