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
## %######################################################%## | |
# # | |
#### Regex for data cleaning - your turn #### | |
# # | |
## %######################################################%## | |
# 1. Download CRAN package descriptions | |
# 2. Select Package name, author, description, and all variables that end in 'ports' | |
# 3. Filter rows for packages with names that: | |
# - end in plot |
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
## %######################################################%## | |
# # | |
#### Understanding a regular expression - your turn #### | |
# # | |
## %######################################################%## | |
# Write regular expressions to match: | |
# Test with stringr, regexplain, or a web-based regex tester | |
# "cute, cuuute, cuuuuuute, and cuuuuuuuuute" |
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(ggplot2) | |
library(dplyr) | |
# datos internos que vienen con ggplot2 | |
animals <- | |
msleep %>% slice_max(sleep_rem, n = 30) %>% # seleccionando top 30 | |
ggplot(aes(x = forcats::fct_reorder(name, sleep_total), y = sleep_total, label = name)) + | |
geom_bar(stat = "identity") + xlab("") + | |
geom_text(nudge_y = 2, hjust = 0) + | |
theme( |
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
# 2020 (2019) AKC dog bump chart | |
library(ggplot2) # CRAN v3.3.0 | |
library(ggbump) # CRAN v0.1.0 | |
library(dplyr) # [github::tidyverse/dplyr] v0.8.99.9003 | |
library(tidyr) # CRAN v1.0.3 | |
library(ggimage) # CRAN v0.2.8 | |
library(scico) # CRAN v1.1.0 | |
library(extrafont) # CRAN v0.17 | |
# make dataset |
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(purrr) | |
library(dplyr) | |
library(here) | |
library(magick) | |
library(fs) | |
library(stringr) | |
library(ggplot2) | |
library(ggimage) | |
library(tidyr) | |
library(hrbrthemes) |
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
# shot richness | |
# access shot chart data from the API | |
library(nbastatR) | |
# team shot chart stats | |
mavs <- teams_shots( | |
teams = "Dallas Mavericks", | |
seasons = 2019 | |
) | |
hawks <- teams_shots( |
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(nbastatR) # if needed install_github("abresler/nbastatR") if needed | |
# id for Devin Booker franchise scoring record vs Boston | |
phoBos <- 21601076 | |
# team shot chart for 2017 season | |
phx <- teams_shots(teams = "Phoenix Suns", | |
seasons = 2017) | |
library(dplyr) | |
library(stringr) |
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(nbastatR) #install_github("abresler/nbastatR") if needed | |
# team shot chart for current season | |
hou <- teams_shots(teams = "Houston Rockets", | |
seasons = 2019) | |
library(dplyr) # because some functions conflict | |
last3games <- hou %>% select(idGame) %>% | |
unique() %>% top_n(3) %>% pull(idGame) |
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(dplyr) | |
library(ggplot2) | |
library(gganimate) | |
library(tidyr) | |
library(stringr) | |
library(extrafont) | |
# set up data | |
dat <- data_frame(type=sort(rep(c("canine","feline","avian"),3)), | |
name=c("Sam","Austin","Squawk", |
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(dplyr) | |
library(tidyr) | |
survey <- data_frame(ID= factor(seq.int(1,6,1)), answers=c("a","b,c","d,e","c,d","b,c,e","e")) | |
survey %>% unnest(answers=strsplit(answers,",")) | |
# A tibble: 11 x 2 |