Skip to content

Instantly share code, notes, and snippets.

🇦🇺
In Australia

Nicholas Tierney njtierney

🇦🇺
In Australia
Block or report user

Report or block njtierney

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View console-text-case-when.md
library(tidyverse)
df_console <- tibble(
  name = c("Smash Bros.", "Red Dead", "Spiderman 4", "Overcooked", "Zelda"),
  sales = c(2001:2005),
  platform = c("NS",
               "PS4",
               "PS4)(PS4",
               "NS(2017)",
               "XboxOne")
View example-issue-w-numeric-char.md
library(tidyverse)
library(glue)
#> 
#> Attaching package: 'glue'
#> The following object is masked from 'package:dplyr':
#> 
#>     collapse
library(lubridate)
#> 
View change-colours.md
library(tidyverse)

ggplot(airquality,
       aes(x = Ozone)) + 
  geom_histogram(fill = "red")
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#> Warning: Removed 37 rows containing non-finite values (stat_bin).
View dplyr-across.md
library(tidyverse)
income <- tibble(income_range = c("0-74",
                                  "75-145",
                                  "150-325",
                                  "325+"),
                 count = c(125,
                           170, 
                           215,
                           250))
View who-label.md
library(tidyverse)
who_tidy <- who %>% pivot_longer(
    cols = new_sp_m014:newrel_f65,
    names_to = c("diagnosis", "gender", "age"),
    names_pattern = "new_?(.*)_(.)(.*)",
    values_to = "count"
  )

who_tidy
View splitting-into-chunks.md
library(tidyverse)
chunk <- function(x, n){
  split(x, sort(x %% n))
}

special_chunk <- function(x, n){
  chunk(x, n) %>% 
    map(paste0, collapse = ", ") %>% 
    as.character()
View join-bands.md
library(tidyverse)
top_100 <- tibble(artist = c("The Beatles", "The Mars Volta"), 
                  song = c("Help!", "Cicatriz Esp"))

rock_tibble <- tibble(artist = "The Beatles",
                      song = "Help!") 

prog_rock_tibble <- tibble(artist = "The Mars Volta",
                           song = "Cicatriz Esp")
View example-lyrics.Rmd
---
class: bg-main1
# Let's get more data
.huge[
We'll use the `genius` package to get song lyric data from [Genius](https://genius.com/).
- `genius_album()` allows you to download the lyrics for an entire album in a
tidy format.
View dt-split.md
library(tidyverse)
library(rpart)
set.seed(2020 - 05 - 21)
x <- sort(runif(100) - 0.5)
df <- tibble(x,
             y = 10 * c(x[1:50] ^ 2,
                        x[51:75] * 2,
                        -x[76:100] ^ 2) + rnorm(100) * 0.5)
View read-rates.R
library(tidyverse)
library(gridExtra)
rates <- read_csv("https://raw.githubusercontent.com/numbats/ida/master/slides/data/rates_new.csv")
rates <- rates %>%
distinct() %>%
arrange(date)
p1 <- ggplot(rates, aes(x=date, y=AUD)) + geom_line()
p2 <- ggplot(rates, aes(x=date, y=EUR)) + geom_line()
You can’t perform that action at this time.