This file contains 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
## UNTANGLE FUNCTION | |
# Luis D. Verde (www.liomys.mx) | |
#' Pull interspersed header data into own column | |
#' | |
#' @param dframe The tibble or data frame with the interspersed headers in the first column | |
#' @param matchstring the string to match to pull the header rows (quoted character) | |
#' @param newCol name for the new variable that will be added to the df (quoted char) | |
#' @return a tbl or df (depending on the input) with the interspersed headers in their own column | |
#' @export | |
#' |
This file contains 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
# define function | |
# this code is just for fun and I do not have rights to the images on dogtime.com I just like dogs | |
ggpupBV <- function(ggplotObject,breedVector){ | |
# required packages | |
require(dplyr) | |
require(jpeg) | |
require(grid) | |
require(gridExtra) |
This file contains 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) | |
library(stringr) | |
library(purrr) | |
survey <- data_frame(ID= factor(seq.int(1,6,1)), answers=c("a","b,c","d,e","c,d","b,c,e","e")) | |
#survey %>% | |
map(survey$answers,strsplit,",") |
This file contains 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 |
This file contains 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 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 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 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 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 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 |