Load library
library(rvest)## Loading required package: xml2
Load Data
pagesource = read_html('http://www.livefootball.com/football/england/premier-league/')
versionblock = html_nodes(pagesource,'td')
content = html_text(versionblock)Clean Data
content = matrix(content, ncol = 10, byrow = T)
content = as.data.frame(content, stringsAsFactors = F)
colnames(content) = content[1,]
content = content[-1,]
content$GD = as.numeric(content$F) - as.numeric(content$A)
rownames(content) = content[,1]
content = content[,-1]
knitr::kable(content)| Team Name | P | W | D | L | F | A | GD | PTS |
|---|---|---|---|---|---|---|---|---|
| Leicester City | 38 | 23 | 12 | 3 | 68 | 36 | 32 | 81 |
| Arsenal | 38 | 20 | 11 | 7 | 65 | 36 | 29 | 71 |
| Tottenham Hotspur | 38 | 19 | 13 | 6 | 69 | 35 | 34 | 70 |
| Manchester City | 38 | 19 | 9 | 10 | 71 | 41 | 30 | 66 |
| Southampton | 38 | 18 | 9 | 11 | 59 | 41 | 18 | 63 |
| Manchester United | 37 | 18 | 9 | 10 | 46 | 34 | 12 | 63 |
| West Ham United | 38 | 16 | 14 | 8 | 65 | 51 | 14 | 62 |
| Liverpool | 38 | 16 | 12 | 10 | 63 | 50 | 13 | 60 |
| Stoke City | 38 | 14 | 9 | 15 | 41 | 55 | -14 | 51 |
| Chelsea | 38 | 12 | 14 | 12 | 59 | 53 | 6 | 50 |
| Everton | 38 | 11 | 14 | 13 | 59 | 55 | 4 | 47 |
| Swansea City | 38 | 12 | 11 | 15 | 42 | 52 | -10 | 47 |
| Watford | 38 | 12 | 9 | 17 | 40 | 50 | -10 | 45 |
| West Bromwich Albion | 38 | 10 | 13 | 15 | 34 | 48 | -14 | 43 |
| Crystal Palace | 38 | 11 | 9 | 18 | 39 | 51 | -12 | 42 |
| AFC Bournemouth | 37 | 11 | 9 | 17 | 44 | 64 | -20 | 42 |
| Sunderland | 38 | 9 | 12 | 17 | 48 | 62 | -14 | 39 |
| Newcastle United | 38 | 9 | 10 | 19 | 44 | 65 | -21 | 37 |
| Norwich City | 38 | 9 | 7 | 22 | 39 | 67 | -28 | 34 |
| Aston Villa | 38 | 3 | 8 | 27 | 27 | 76 | -49 | 17 |