Skip to content

Instantly share code, notes, and snippets.

View will-r-chase's full-sized avatar

William Chase will-r-chase

View GitHub Profile
library(tidyverse)
plastics <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2021/2021-01-26/plastics.csv')
bar_chart <-
plastics %>%
group_by(parent_company) %>%
summarize(total = sum(grand_total, na.rm = TRUE)) %>%
arrange(desc(total)) %>%
slice(4:14) %>%
library(tidyverse)
library(patchwork)
#Your turn
#You can either use your own charts or the charts provided in plastic_charts.R
#Create a patchwork with one chart in a lefthand column
#spanning two vertical rows, and two charts in a second column
#stacked on top of each other
##Solution
library(tidyverse)
#plastic pollution dataset
plastics <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2021/2021-01-26/plastics.csv')
#wrangle data
data <- plastics %>%
group_by(parent_company) %>%
summarize(total = sum(grand_total, na.rm = TRUE)) %>%
##Your turn
library(tidyverse)
#plastic pollution dataset
plastics <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2021/2021-01-26/plastics.csv')
#Take a plot you made with the plastic pollution dataset (it doesn't need to be a scatter plot)
#And apply the principles you learned about for axes, grids, borders, etc.
#If you don't want to use your own plot, you can use this one...
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Year Glob NHem SHem 24N-90N 24S-24N 90S-24S 64N-90N 44N-64N 24N-44N EQU-24N 24S-EQU 44S-24S 64S-44S 90S-64S
1880 -.16 -.27 -.04 -.35 -.13 -.01 -.82 -.45 -.26 -.15 -.10 -.03 .05 .65
1881 -.07 -.16 .01 -.32 .10 -.06 -.92 -.41 -.17 .10 .11 -.04 -.07 .57
1882 -.10 -.20 -.01 -.28 -.05 .02 -1.41 -.24 -.11 -.05 -.05 .02 .04 .61
1883 -.16 -.26 -.06 -.31 -.16 .00 -.19 -.53 -.22 -.17 -.15 -.03 .07 .48
1884 -.27 -.41 -.14 -.58 -.15 -.13 -1.31 -.62 -.43 -.13 -.16 -.18 -.02 .63
1885 -.33 -.43 -.24 -.64 -.13 -.27 -1.52 -.66 -.44 -.07 -.20 -.33 -.15 .80
1886 -.31 -.42 -.20 -.55 -.20 -.21 -1.59 -.48 -.38 -.21 -.18 -.19 -.21 .57
1887 -.35 -.43 -.28 -.51 -.30 -.28 -1.77 -.48 -.27 -.29 -.30 -.27 -.26 .30
1888 -.17 -.23 -.12 -.41 .09 -.28 -1.31 -.41 -.23 .06 .12 -.30 -.22 .14
id x y
1 4.39254690214287 0.6542013379024343
1 2.409 1.7994026758048691
1 0.4254530978571296 0.6542013379024352
1 0.4254530978571289 -1.6362013379024343
1 2.4089999999999994 -2.7814026758048693
1 4.39254690214287 -1.6362013379024358
1 4.39254690214287 0.6542013379024345
2 -0.3909999999999999 11.50367047480547
2 -2.2880443529252883 10.125387074892835
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
We can make this file beautiful and searchable if this error is corrected: It looks like row 6 should actually have 23 columns, instead of 13. in line 5.
name,start_month,start_day,end_month,end_day,year,peak_classification,wind_speed_mph,wind_speed_kmh,pressure_hPa,pressure_inHg,areas_affected,eastern_seaboard,gulf_coast,caribbean,central_america,deaths,damage,start_date,end_date,adj_factor,damage_inflation_adjusted,name_date
Carol,August,25,September,1,1954,3,115,185,955,28.2,"Northeastern United States, Canada",3,0,0,0,60,462000000,1954-08-25,1954-09-01,9.51,4393620000,Carol_1954-08-25
Edna,September,5,September,11,1954,3,125,205,943,27.85,"New England, Atlantic Canada",2,0,TS,0,21,42000000,1954-09-05,1954-09-11,9.49,398580000,Edna_1954-09-05
Hazel,October,5,October,15,1954,4,130,210,938,27.7,"The Caribbean, Eastern United States, Canada",4,0,3,0,581,382000000,1954-10-05,1954-10-15,9.49,3625180000,Hazel_1954-10-05
Connie,August,3,August,15,1955,4,140,220,944,27.88,"Mid-Atlantic states, New England",2,0,0,0,25,40000000,1955-08-03,1955-08-15,9.51,380400000,Connie_1955-08-03
Diane,August,7,August,21,1955,2,105,165,969,28.61,"Mid-Atlantic states, New England",1