Skip to content

Instantly share code, notes, and snippets.

💭
Looking for work opportunities

Luis Verde Arregoitia luisDVA

💭
Looking for work opportunities
Block or report user

Report or block luisDVA

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
@luisDVA
luisDVA / dog-ranks-2020.R
Created May 13, 2020
Dog popularity bump chart
View dog-ranks-2020.R
# 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
@luisDVA
luisDVA / dog-ranks-2019.R
Last active Apr 29, 2019
do breed bump chart - new
View dog-ranks-2019.R
library(purrr)
library(dplyr)
library(here)
library(magick)
library(fs)
library(stringr)
library(ggplot2)
library(ggimage)
library(tidyr)
library(hrbrthemes)
@luisDVA
luisDVA / shot-richness.R
Created Feb 14, 2019
point proximity overlap for NBA shot chart data
View shot-richness.R
# 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(
@luisDVA
luisDVA / shots-location.R
Created Jan 9, 2019
animate shot distances and locations side by side
View shots-location.R
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)
@luisDVA
luisDVA / shot-distances.R
Created Jan 5, 2019
animate b-ball shot distances
View shot-distances.R
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)
@luisDVA
luisDVA / animatetopn.R
Created Aug 16, 2018
tidyverse demo animation
View animatetopn.R
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",
View file2ab65b2b6ad.R
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
View file2a2b2563f169.R
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,",")
@luisDVA
luisDVA / expandSeries.R
Created Jun 27, 2017
vectorized fn to expand a series (consecutive IDs implied)
View expandSeries.R
# expanding a series, consecutive values
# by Filipe Chichorro, modified for vectors
expandSeries <- function(strStartEnd){
words<-strsplit(strStartEnd, " ")
if (length(words[[1]])== 1) return(strStartEnd)
else
@luisDVA
luisDVA / untangleFunction.R
Created Jun 26, 2017
function to untangle header rows from a variable
View untangleFunction.R
## 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
#'
You can’t perform that action at this time.