Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
31 lines (23 sloc) 1.27 KB
---
title: "CapsOfTimelineMatches"
output: html_document
---
HARD CODED LINE BELOW:
```{r}
library(rvest)
html.vector <- readLines("http://stats.espnscrum.com/statsguru/rugby/stats/index.html?class=1;filter=advanced;opposition=12;opposition=16;opposition=20;opposition=3;opposition=4;opposition=6;opposition=81;opposition=9;orderby=matches;size=200;spanmin1=27+Mar+2016;spanval1=span;team=23;template=results;type=player")
strings.including.names <- html.vector[grep("[[:punct:]][>][[:upper:]]{1,2}[[:space:]][[:upper:]]{0,1}[[:lower:]]", html.vector)[1:55]]
#hard coded line above because we know there are only 55 players
strings.including.names
strings.including.caps <- html.vector[grep("[[:punct:]][>][[:upper:]]{1,2}[[:space:]][[:upper:]]{0,1}[[:lower:]]", html.vector)[1:55]+2]
#hard coded line above because we know there are only 55 players
strings.including.caps
```
Substring strings.including.caps and the strings.including.caps
```{r}
names <- unlist(regmatches(strings.including.names, regexpr("[[:upper:]]{1,2}[[:space:]][[:upper:]]{0,1}[[:upper:][:lower:][:space:]]{1,}",strings.including.names)))
names
caps <- as.integer(unlist(regmatches(strings.including.caps, regexpr("[0-9]{1,3}",strings.including.caps))))
caps
write.csv(data.frame(names,caps), "names.caps.csv")
```