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(tidyverse) | |
library(magrittr) | |
library(rvest) | |
webpage <- read_html("https://en.wikipedia.org/wiki/List_of_tournament_performances_by_Tiger_Woods") | |
l <- webpage %>% html_nodes("table.wikitable") %>% html_table() | |
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
## Drawing consonants in a row | |
tiles <- c(rep("V", 44), rep("C", 56)) # 42 vowels + 2 blanks, 56 consonants | |
# combined vowels and blanks into "V" as don't care about difference for this | |
# loop 1 million times | |
res<-NULL | |
for(i in 1:1000000){ | |
draw <- sample(tiles, 17, F) |
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(engsoccerdata) | |
library(tidyverse) | |
england %>% | |
filter(tier==1) %>% | |
split(.$Season) %>% | |
map(function(x) maketable_eng(x, Season = x$Season[1], tier=1, penalties=T) ) %>% | |
map(~summarise(., diff = Pts[Pos==1] - Pts[Pos==2])) %>% | |
bind_rows %>% | |
ggplot(aes(x=diff))+geom_histogram(color='black', fill="gray62", binwidth = 1) + scale_x_continuous(breaks = seq(0,20,2)) + |
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
country | lifeExp | |
---|---|---|
Afghanistan | 43.828 | |
Albania | 76.423 | |
Algeria | 72.301 | |
Angola | 42.731 | |
Argentina | 75.32 | |
Australia | 81.235 | |
Austria | 79.829 | |
Bahrain | 75.635 | |
Bangladesh | 64.062 |
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(tidyverse) | |
library(engsoccerdata) | |
england %>% | |
filter(tier==1) %>% | |
homeaway() %>% | |
group_by(team) %>% | |
arrange(Date) %>% | |
filter(venue=="away") %>% | |
mutate(gameno = row_number())%>% |
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
license: mit |
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
### Comparing Arsenal Points per N games over time | |
library(engsoccerdata) | |
library(tidyverse) | |
rollpts <- function(teamname=NULL, N=10){ | |
rbind(england,england_current()) %>% | |
homeaway() %>% | |
filter(team==teamname) %>% | |
mutate(pts = ifelse(gf>ga, 3, ifelse(gf<ga, 0, 1)), |
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
license: mit |
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
expandrows <- function(df){ | |
library(splitstackshape) | |
library(data.table) | |
temp <- cSplit(cSplit(cbind(id = 1:nrow(df), df), | |
"Actor", ",", "long"), | |
"Recipient", ",", "long") | |
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
Timestamp | Actor | Behavior | Recipient | Location | Observer | Notes | |
---|---|---|---|---|---|---|---|
10/14/2014 11:57:16 | Start | Start | Start | Start | CW | NA | |
10/14/2014 12:03:10 | 6 | Mounting | 10 | NB4 | CW | NA | |
10/14/2014 12:04:16 | 6 | Fighting | 5 | NB5 | CW | NA | |
10/14/2014 12:19:27 | 3 | Fighting | 4 | ML | CW | NA | |
10/14/2014 12:28:05 | 4 | Subordinate | 10 | LL | CW | NA | |
10/14/2014 12:30:49 | 4 | Fighting | 2 | NB1 | CW | NA | |
10/14/2014 12:34:39 | 4 | Fighting | 2 | NB5 | CW | NA | |
10/14/2014 12:40:36 | 4 | Subordinate | 1 | NB5 | CW | NA | |
10/14/2014 12:44:08 | 4 | Chasing | 11 | LL, LR | CW | NA |