Last active
December 19, 2015 00:29
-
-
Save pssguy/5869377 to your computer and use it in GitHub Desktop.
Test. EPL charts and lineups
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
| gameDate | team | venue | GF | GA | opposition | MATCHID | TEAMMATCHID | result | season | seasonGame | GD | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1992-08-15 | Arsenal | H | 2 | 4 | Norwich C | 1313 | 20000 | L | 1992/1993 | 1 | -2 | |
| 1992-08-23 | Arsenal | A | 2 | 0 | Liverpool | 1345 | 21032 | W | 1992/1993 | 3 | 2 | |
| 1992-09-02 | Arsenal | A | 0 | 0 | QPR | 1374 | 21061 | D | 1992/1993 | 6 | 0.2 | |
| 1992-08-23 | Liverpool | H | 0 | 2 | Arsenal | 1345 | 20032 | L | 1992/1993 | 3 | -2 | |
| 1992-08-15 | Norwich C | A | 4 | 2 | Arsenal | 1313 | 21000 | W | 1992/1993 | 1 | 2 | |
| 1992-09-02 | QPR | H | 0 | 0 | Arsenal | 1374 | 20061 | D | 1992/1993 | 6 | 0.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
| # needed for full version | |
| require(rCharts) | |
| require(shiny) | |
| require(reshape2) | |
| library(sqldf) | |
| library(plyr) | |
| library(lubridate) | |
| library(stringr) | |
| library(zoo) | |
| library(XML) | |
| Lineups <- read.csv("Lineups.csv", stringsAsFactors=FALSE) | |
| tables_dt_print <- read.csv("tables_dt_print.csv", stringsAsFactors=FALSE) | |
| gameResults <-read.csv("gameResults.csv", stringsAsFactors=FALSE) | |
| seasonChoice <- sort(unique(gameResults$season)) | |
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 | PLAYERID | BIRTHDATE | POSITION | FIRSTNAME | LASTNAME | TEAMID | Goals | TEAMNAME | Opponents | OppID | START | subOn | OFF | PENS | CARD | Result | OwnGoal | gameDate | venue | Assists | TEAMMATCHID | MATCHID | iso2c | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Cyprus | GOSSJ | 1965-05-11 | M | Jeremy | Goss | NOR | 0 | Norwich C | Arsenal | ARS | 3 | 0 | 0 | 0 | NA | W | NA | 1992-08-15 | A | 2 | 21000 | 1313 | CY | |
| Denmark | MOLBYJ | 1963-07-04 | M | Jan | Molby | LIV | 0 | Liverpool | Arsenal | ARS | 3 | 0 | 0 | 0 | NA | L | NA | 1992-08-23 | H | NA | 20032 | 1345 | DK | |
| Denmark | JENSENJ | 1965-05-03 | M | John | Jensen | ARS | 0 | Arsenal | QPR | QPR | 3 | 0 | 0 | 0 | NA | N | NA | 1992-09-02 | A | NA | 21061 | 1374 | DK | |
| Denmark | JENSENJ | 1965-05-03 | M | John | Jensen | ARS | 0 | Arsenal | Norwich C | NOR | 3 | 0 | 0 | 0 | NA | L | NA | 1992-08-15 | H | NA | 20000 | 1313 | DK | |
| Denmark | JENSENJ | 1965-05-03 | M | John | Jensen | ARS | 0 | Arsenal | Liverpool | LIV | 4 | 0 | 0 | 0 | Y | W | NA | 1992-08-23 | A | NA | 21032 | 1345 | DK | |
| England | CULVERI | 1964-09-22 | D | Ian | Culverhouse | NOR | 0 | Norwich C | Arsenal | ARS | 3 | 0 | 0 | 0 | NA | W | NA | 1992-08-15 | A | NA | 21000 | 1313 | EN | |
| England | BUTTERI | 1965-01-25 | D | Ian | Butterworth | NOR | 0 | Norwich C | Arsenal | ARS | 3 | 0 | 0 | 0 | NA | W | NA | 1992-08-15 | A | NA | 21000 | 1313 | EN | |
| England | POLSTOJ | 1968-06-10 | D | John | Polston | NOR | 0 | Norwich C | Arsenal | ARS | 4 | 0 | 0 | 0 | NA | W | NA | 1992-08-15 | A | NA | 21000 | 1313 | EN | |
| England | MEGSONG | 1959-05-02 | M | Gary | Megson | NOR | 0 | Norwich C | Arsenal | ARS | 4 | 0 | 99 | 0 | NA | W | NA | 1992-08-15 | A | NA | 21000 | 1313 | EN | |
| England | FOXR | 1968-01-14 | Midfielder | Ruel | Fox | NOR | 1 | Norwich C | Arsenal | ARS | 4 | 0 | 0 | 0 | NA | W | NA | 1992-08-15 | A | NA | 21000 | 1313 | EN | |
| England | NEWMANR1 | 1963-12-13 | D | Rob | Newman | NOR | 0 | Norwich C | Arsenal | ARS | 3 | 0 | 0 | 0 | NA | W | NA | 1992-08-15 | A | NA | 21000 | 1313 | EN | |
| England | SUTTONC | 1973-03-10 | Forward | Chris | Sutton | NOR | 0 | Norwich C | Arsenal | ARS | 3 | 0 | 99 | 0 | NA | W | NA | 1992-08-15 | A | NA | 21000 | 1313 | EN | |
| England | ROBINSM1 | 1969-12-22 | F | Mark | Robins | NOR | 2 | Norwich C | Arsenal | ARS | 0 | 99 | 0 | 0 | NA | W | NA | 1992-08-15 | A | NA | 21000 | 1313 | EN | |
| England | CROOKI | 1963-01-18 | M | Ian | Crook | NOR | 0 | Norwich C | Arsenal | ARS | 0 | 99 | 0 | 0 | NA | W | NA | 1992-08-15 | A | NA | 21000 | 1313 | EN | |
| England | SEAMAND | 1963-09-19 | Goalkeeper | David | Seaman | ARS | 0 | Arsenal | Norwich C | NOR | 2 | 0 | 0 | 0 | NA | L | NA | 1992-08-15 | H | NA | 20000 | 1313 | EN | |
| England | DIXONL | 1964-03-17 | Defender | Lee | Dixon | ARS | 0 | Arsenal | Norwich C | NOR | 3 | 0 | 0 | 0 | NA | L | NA | 1992-08-15 | H | 1 | 20000 | 1313 | EN | |
| England | WINTERN | 1963-12-11 | Defender | Nigel | Winterburn | ARS | 0 | Arsenal | Norwich C | NOR | 3 | 0 | 0 | 0 | NA | L | NA | 1992-08-15 | H | 1 | 20000 | 1313 | EN | |
| England | HILLIED | 1969-12-19 | M | David | Hillier | ARS | 0 | Arsenal | Norwich C | NOR | 3 | 0 | 0 | 0 | NA | L | NA | 1992-08-15 | H | NA | 20000 | 1313 | EN | |
| England | BOULDS | 1962-11-16 | Defender | Steve | Bould | ARS | 1 | Arsenal | Norwich C | NOR | 3 | 0 | 0 | 0 | NA | L | NA | 1992-08-15 | H | NA | 20000 | 1313 | EN | |
| England | ADAMST | 1966-10-10 | Defender | Tony | Adams | ARS | 0 | Arsenal | Norwich C | NOR | 3 | 0 | 0 | 0 | NA | L | NA | 1992-08-15 | H | NA | 20000 | 1313 | EN | |
| England | SMITHA1 | 1962-11-21 | F | Alan | Smith | ARS | 0 | Arsenal | Norwich C | NOR | 3 | 0 | 0 | 0 | NA | L | NA | 1992-08-15 | H | NA | 20000 | 1313 | EN | |
| England | CAMPBEK | 1970-02-04 | F | Kevin | Campbell | ARS | 1 | Arsenal | Norwich C | NOR | 4 | 0 | 0 | 0 | NA | L | NA | 1992-08-15 | H | NA | 20000 | 1313 | EN | |
| England | MERSONP | 1968-03-20 | F | Paul | Merson | ARS | 0 | Arsenal | Norwich C | NOR | 2 | 0 | 99 | 0 | NA | L | NA | 1992-08-15 | H | NA | 20000 | 1313 | EN | |
| England | WRIGHTI1 | 1963-11-03 | F | Ian | Wright | ARS | 0 | Arsenal | Norwich C | NOR | 0 | 99 | 0 | 0 | NA | L | NA | 1992-08-15 | H | NA | 20000 | 1313 | EN | |
| England | PATESC | 1961-08-10 | D | Colin | Pates | ARS | 0 | Arsenal | Norwich C | NOR | 0 | 0 | 0 | 0 | NA | O | NA | 1992-08-15 | H | NA | 20000 | 1313 | EN | |
| England | JAMESD | 1970-08-01 | Goalkeeper | David | James | LIV | 0 | Liverpool | Arsenal | ARS | 5 | 0 | 0 | 0 | NA | L | NA | 1992-08-23 | H | NA | 20032 | 1345 | EN | |
| England | BURROWD | 1968-10-25 | Defender | David | Burrows | LIV | 0 | Liverpool | Arsenal | ARS | 3 | 0 | 0 | 0 | NA | L | NA | 1992-08-23 | H | NA | 20032 | 1345 | EN | |
| England | WRIGHTM1 | 1963-08-01 | D | Mark | Wright | LIV | 0 | Liverpool | Arsenal | ARS | 3 | 0 | 0 | 0 | NA | L | NA | 1992-08-23 | H | NA | 20032 | 1345 | EN | |
| England | MCMANAS1 | 1972-02-11 | M | Steve | McManaman | LIV | 0 | Liverpool | Arsenal | ARS | 3 | 0 | 0 | 0 | NA | L | NA | 1992-08-23 | H | NA | 20032 | 1345 | EN | |
| England | THOMASM1 | 1967-08-24 | M | Michael | Thomas | LIV | 0 | Liverpool | Arsenal | ARS | 3 | 0 | 99 | 0 | NA | L | NA | 1992-08-23 | H | NA | 20032 | 1345 | EN | |
| England | WALTERM | 1964-06-02 | F | Mark | Walters | LIV | 0 | Liverpool | Arsenal | ARS | 4 | 0 | 0 | 0 | NA | L | NA | 1992-08-23 | H | NA | 20032 | 1345 | EN | |
| England | TANNERN | 1965-05-24 | D | Nicky | Tanner | LIV | 0 | Liverpool | Arsenal | ARS | 3 | 0 | 0 | 0 | NA | L | NA | 1992-08-23 | H | NA | 20032 | 1345 | EN | |
| England | MARSHM | 1969-07-21 | M | Mike | Marsh | LIV | 0 | Liverpool | Arsenal | ARS | 0 | 99 | 0 | 0 | NA | L | NA | 1992-08-23 | H | NA | 20032 | 1345 | EN | |
| England | SEAMAND | 1963-09-19 | Goalkeeper | David | Seaman | ARS | 0 | Arsenal | Liverpool | LIV | 3 | 0 | 0 | 0 | NA | W | NA | 1992-08-23 | A | NA | 21032 | 1345 | EN | |
| England | DIXONL | 1964-03-17 | Defender | Lee | Dixon | ARS | 0 | Arsenal | Liverpool | LIV | 3 | 0 | 0 | 0 | Y | W | NA | 1992-08-23 | A | NA | 21032 | 1345 | EN | |
| England | WINTERN | 1963-12-11 | Defender | Nigel | Winterburn | ARS | 0 | Arsenal | Liverpool | LIV | 3 | 0 | 0 | 0 | NA | W | NA | 1992-08-23 | A | NA | 21032 | 1345 | EN | |
| England | HILLIED | 1969-12-19 | M | David | Hillier | ARS | 0 | Arsenal | Liverpool | LIV | 3 | 0 | 0 | 0 | NA | W | NA | 1992-08-23 | A | NA | 21032 | 1345 | EN | |
| England | ADAMST | 1966-10-10 | Defender | Tony | Adams | ARS | 0 | Arsenal | Liverpool | LIV | 3 | 0 | 0 | 0 | NA | W | NA | 1992-08-23 | A | NA | 21032 | 1345 | EN | |
| England | CAMPBEK | 1970-02-04 | F | Kevin | Campbell | ARS | 0 | Arsenal | Liverpool | LIV | 4 | 0 | 0 | 0 | NA | W | NA | 1992-08-23 | A | NA | 21032 | 1345 | EN | |
| England | MERSONP | 1968-03-20 | F | Paul | Merson | ARS | 0 | Arsenal | Liverpool | LIV | 0 | 99 | 0 | 0 | NA | W | NA | 1992-08-23 | A | NA | 21032 | 1345 | EN | |
| England | WRIGHTI1 | 1963-11-03 | F | Ian | Wright | ARS | 1 | Arsenal | Liverpool | LIV | 4 | 0 | 0 | 0 | NA | W | NA | 1992-08-23 | A | NA | 21032 | 1345 | EN | |
| England | PATESC | 1961-08-10 | D | Colin | Pates | ARS | 0 | Arsenal | Liverpool | LIV | 4 | 0 | 0 | 0 | NA | W | NA | 1992-08-23 | A | NA | 21032 | 1345 | EN | |
| England | PARLOUR | 1973-03-07 | Midfielder | Ray | Parlour | ARS | 0 | Arsenal | Liverpool | LIV | 4 | 0 | 0 | 0 | Y | W | NA | 1992-08-23 | A | 2 | 21032 | 1345 | EN | |
| England | OLEARYD | 1958-05-02 | D | David | O'Leary | ARS | 0 | Arsenal | Liverpool | LIV | 0 | 0 | 0 | 0 | NA | O | NA | 1992-08-23 | A | NA | 21032 | 1345 | EN | |
| England | BARDSLD | 1964-09-11 | D | David | Bardsley | QPR | 0 | QPR | Arsenal | ARS | 4 | 0 | 0 | 0 | NA | N | NA | 1992-09-02 | H | NA | 20061 | 1374 | EN | |
| England | WILSONC | 1961-11-13 | Midfielder | Clive | Wilson | QPR | 0 | QPR | Arsenal | ARS | 3 | 0 | 0 | 0 | NA | N | NA | 1992-09-02 | H | NA | 20061 | 1374 | EN | |
| England | WILKINR | 1956-09-14 | M | Ray | Wilkins | QPR | 0 | QPR | Arsenal | ARS | 4 | 0 | 0 | 0 | Y | N | NA | 1992-09-02 | H | NA | 20061 | 1374 | EN | |
| England | PEACOCD2 | 1968-02-03 | D | Darren | Peacock | QPR | 0 | QPR | Arsenal | ARS | 4 | 0 | 0 | 0 | NA | N | NA | 1992-09-02 | H | NA | 20061 | 1374 | EN | |
| England | IMPEYA | 1971-09-13 | Forward | Andy | Impey | QPR | 0 | QPR | Arsenal | ARS | 4 | 0 | 0 | 0 | NA | N | NA | 1992-09-02 | H | NA | 20061 | 1374 | EN | |
| England | FERDINL | 1966-12-18 | Forward | Les | Ferdinand | QPR | 0 | QPR | Arsenal | ARS | 4 | 0 | 0 | 0 | Y | N | NA | 1992-09-02 | H | NA | 20061 | 1374 | EN | |
| England | BAILEYD | 1965-11-13 | F | Dennis | Bailey | QPR | 0 | QPR | Arsenal | ARS | 4 | 0 | 99 | 0 | NA | N | NA | 1992-09-02 | H | NA | 20061 | 1374 | EN | |
| England | SINTONA | 1966-03-19 | Midfielder | Andy | Sinton | QPR | 0 | QPR | Arsenal | ARS | 3 | 0 | 0 | 0 | Y | N | NA | 1992-09-02 | H | NA | 20061 | 1374 | EN | |
| England | MADDIXD | 1967-10-11 | D | Danny | Maddix | QPR | 0 | QPR | Arsenal | ARS | 0 | 0 | 0 | 0 | NA | O | NA | 1992-09-02 | H | NA | 20061 | 1374 | EN | |
| England | PENRICG | 1964-03-23 | M | Gary | Penrice | QPR | 0 | QPR | Arsenal | ARS | 0 | 99 | 0 | 0 | NA | N | NA | 1992-09-02 | H | NA | 20061 | 1374 | EN | |
| England | BARKERS | 1964-11-04 | M | Simon | Barker | QPR | 0 | QPR | Arsenal | ARS | 4 | 0 | 0 | 0 | NA | N | NA | 1992-09-02 | H | NA | 20061 | 1374 | EN | |
| England | SEAMAND | 1963-09-19 | Goalkeeper | David | Seaman | ARS | 0 | Arsenal | QPR | QPR | 3 | 0 | 0 | 0 | NA | N | NA | 1992-09-02 | A | NA | 21061 | 1374 | EN | |
| England | DIXONL | 1964-03-17 | Defender | Lee | Dixon | ARS | 0 | Arsenal | QPR | QPR | 4 | 0 | 0 | 0 | Y | N | NA | 1992-09-02 | A | NA | 21061 | 1374 | EN | |
| England | WINTERN | 1963-12-11 | Defender | Nigel | Winterburn | ARS | 0 | Arsenal | QPR | QPR | 4 | 0 | 0 | 0 | Y | N | NA | 1992-09-02 | A | NA | 21061 | 1374 | EN | |
| England | HILLIED | 1969-12-19 | M | David | Hillier | ARS | 0 | Arsenal | QPR | QPR | 3 | 0 | 99 | 0 | Y | N | NA | 1992-09-02 | A | NA | 21061 | 1374 | EN | |
| England | BOULDS | 1962-11-16 | Defender | Steve | Bould | ARS | 0 | Arsenal | QPR | QPR | 4 | 0 | 0 | 0 | NA | N | NA | 1992-09-02 | A | NA | 21061 | 1374 | EN | |
| England | ADAMST | 1966-10-10 | Defender | Tony | Adams | ARS | 0 | Arsenal | QPR | QPR | 4 | 0 | 0 | 0 | NA | N | NA | 1992-09-02 | A | NA | 21061 | 1374 | EN | |
| England | SMITHA1 | 1962-11-21 | F | Alan | Smith | ARS | 0 | Arsenal | QPR | QPR | 0 | 99 | 0 | 0 | NA | N | NA | 1992-09-02 | A | NA | 21061 | 1374 | EN | |
| England | CAMPBEK | 1970-02-04 | F | Kevin | Campbell | ARS | 0 | Arsenal | QPR | QPR | 4 | 0 | 0 | 0 | NA | N | NA | 1992-09-02 | A | NA | 21061 | 1374 | EN | |
| England | MERSONP | 1968-03-20 | F | Paul | Merson | ARS | 0 | Arsenal | QPR | QPR | 3 | 0 | 99 | 0 | NA | N | NA | 1992-09-02 | A | NA | 21061 | 1374 | EN | |
| England | WRIGHTI1 | 1963-11-03 | F | Ian | Wright | ARS | 0 | Arsenal | QPR | QPR | 3 | 0 | 0 | 0 | NA | N | NA | 1992-09-02 | A | NA | 21061 | 1374 | EN | |
| England | PATESC | 1961-08-10 | D | Colin | Pates | ARS | 0 | Arsenal | QPR | QPR | 0 | 99 | 0 | 0 | NA | N | NA | 1992-09-02 | A | NA | 21061 | 1374 | EN | |
| England | PARLOUR | 1973-03-07 | Midfielder | Ray | Parlour | ARS | 0 | Arsenal | QPR | QPR | 4 | 0 | 0 | 0 | NA | N | NA | 1992-09-02 | A | NA | 21061 | 1374 | EN | |
| Germany | PHILLID | 1963-07-29 | M | David | Phillips | NOR | 1 | Norwich C | Arsenal | ARS | 3 | 0 | 0 | 0 | NA | W | NA | 1992-08-15 | A | 1 | 21000 | 1313 | DE | |
| Ireland | WHELANR | 1961-09-25 | M | Ronnie | Whelan | LIV | 0 | Liverpool | Arsenal | ARS | 3 | 0 | 0 | 0 | Y | L | NA | 1992-08-23 | H | NA | 20032 | 1345 | IE | |
| Israel | ROSENTR | 1963-10-04 | F | Ronnie | Rosenthal | LIV | 0 | Liverpool | Arsenal | ARS | 0 | 99 | 0 | 0 | NA | L | NA | 1992-08-23 | H | NA | 20032 | 1345 | IL | |
| N. Ireland | MCDONAA | 1963-10-12 | D | Alan | McDonald | QPR | 0 | QPR | Arsenal | ARS | 4 | 0 | 0 | 0 | NA | N | NA | 1992-09-02 | H | NA | 20061 | 1374 | GB | |
| Scotland | GUNNB | 1963-12-22 | G | Bryan | Gunn | NOR | 0 | Norwich C | Arsenal | ARS | 3 | 0 | 0 | 0 | NA | W | NA | 1992-08-15 | A | NA | 21000 | 1313 | SF | |
| Sweden | LIMPARA | 1965-09-24 | M | Anders | Limpar | ARS | 1 | Arsenal | Liverpool | LIV | 5 | 0 | 99 | 0 | NA | W | NA | 1992-08-23 | A | NA | 21032 | 1345 | SE | |
| Sweden | LIMPARA | 1965-09-24 | M | Anders | Limpar | ARS | 0 | Arsenal | Norwich C | NOR | 2 | 0 | 0 | 0 | NA | L | NA | 1992-08-15 | H | NA | 20000 | 1313 | SE | |
| Wales | BOWENM | 1963-12-07 | Defender | Mark | Bowen | NOR | 0 | Norwich C | Arsenal | ARS | 3 | 0 | 0 | 0 | NA | W | NA | 1992-08-15 | A | NA | 21000 | 1313 | WA | |
| Wales | JONESR1 | 1971-11-05 | D | Rob | Jones | LIV | 0 | Liverpool | Arsenal | ARS | 4 | 0 | 99 | 0 | NA | L | NA | 1992-08-23 | H | NA | 20032 | 1345 | WA | |
| Wales | SAUNDED | 1964-06-21 | F | Dean | Saunders | LIV | 0 | Liverpool | Arsenal | ARS | 4 | 0 | 0 | 0 | NA | L | NA | 1992-08-23 | H | NA | 20032 | 1345 | WA | |
| Wales | ROBERTT | 1969-08-04 | G | Tony | Roberts | QPR | 0 | QPR | Arsenal | ARS | 4 | 0 | 0 | 0 | NA | N | NA | 1992-09-02 | H | NA | 20061 | 1374 | WA |
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
| shinyServer(function(input, output) { | |
| # create some conditional uiOutputs | |
| output$teams<- renderUI( { | |
| teamChoice <- sort(unique(gameResults[gameResults$season==input$season,]$team)) | |
| selectInput("team", "Select Team",teamChoice) | |
| }) | |
| # results chart | |
| output$myChart <- renderChart( { | |
| # | |
| input$goButton | |
| isolate({ | |
| print(input$season) | |
| print(input$team) | |
| theTeam <- input$team | |
| if (is.null(theTeam)) theTeam<- "Arsenal" | |
| print(theTeam) | |
| df <- subset(gameResults,team==theTeam&season==input$season) | |
| # print(df) | |
| #df <- subset(gameResults,team=="Arsenal"&season=="1992/1993") | |
| df$showDate <- paste(month(df$gameDate,label = TRUE, abbr=TRUE),day(df$gameDate),year(df$gameDate), sep=" ") | |
| df_orig<- data.frame(x=df$seasonGame, | |
| y=df$GD, | |
| info=sprintf("<table cellpadding='4' style='line-height:1.5'><tr><th align='left'>%1$s</th></tr><tr><td align='center'>%2$s %4$s<br>%3$s</td></tr></table>", | |
| df$showDate, | |
| df$opposition, | |
| paste0(df$GF," - ",df$GA), | |
| paste0("(",df$venue,")") | |
| ), | |
| gameDate = df$gameDate, | |
| result=df$result, | |
| MATCHID=df$MATCHID) | |
| print(df_orig) | |
| b <- rCharts:::Highcharts$new() | |
| invisible(sapply(c("W", "D", "L"), function(res){ | |
| df <- df_orig[df_orig$result == res,] | |
| df.lst <- lapply(1:nrow(df), function(i) as.list(df[i,])) | |
| b$series(data=df.lst, type = "column", name = res) | |
| })) | |
| b$plotOptions( | |
| column = list(pointPadding = -0.25, | |
| groupPadding = 0.1, | |
| pointWidth = 10, | |
| grouping=F, | |
| cursor = "pointer", | |
| point = list( | |
| events = list( | |
| click = "#! function() { | |
| Shiny.onInputChange('info', { | |
| MATCHID: this.MATCHID | |
| }) | |
| } !#")), | |
| marker = list( | |
| symbol = "circle", | |
| radius = 5 | |
| ) | |
| ) | |
| ) | |
| # b$plotOptions(column = list(pointPadding = -0.25, groupPadding = 0.1, pointWidth = 10)) | |
| b$tooltip(useHTML = T,formatter = "#! function() { return this.point.info; } !#") # this works as does anything else in thouh date needs | |
| b$yAxis(title=list(enabled=T,text="Goal Margin"), allowDecimals = FALSE) | |
| b$xAxis(title=list(text="Season Game"), allowDecimals = FALSE) | |
| b$colors('green','blue','red') | |
| b$chart(height=250) | |
| b$set(dom = 'myChart') | |
| return(b) | |
| }) | |
| }) | |
| # Position chart | |
| output$posChart <- renderChart( { | |
| # | |
| input$goButton | |
| isolate({ | |
| print(input$season) | |
| print(input$team) | |
| theTeam <- input$team | |
| if (is.null(theTeam)) theTeam<- "Arsenal" | |
| #df <- subset(tables_dt_print,season=="1992/1993"&team=="Arsenal") | |
| df <- subset(tables_dt_print,season==input$season&team==theTeam) | |
| df <- df[,c(1,2,3,4,12)] | |
| df <- arrange(df,seasonGame) | |
| df_final <- data.frame(x=df$seasonGame,y=df$Pos,Pts=df$cumPoints, | |
| info=sprintf("<table cellpadding='4' style='line-height:1.5'><tr><td align='center'>Position: %1$s<br>Points: %2$s</td></tr></table>", | |
| df$Pos, | |
| df$cumPoints | |
| )) | |
| posSeries <- lapply(split(df_final, rownames(df_final)), as.list) | |
| names(posSeries) <- NULL | |
| posSeries <- posSeries[order(sapply(posSeries, function(x) x$x))] | |
| c <- rCharts::Highcharts$new() | |
| c$series(data=posSeries, type = "line") # Great | |
| c$yAxis(title=list(text="League Position"), reversed = TRUE, allowDecimals = FALSE, min= -5, startOnTick = FALSE) | |
| c$xAxis(title=list(text="Season Game"), allowDecimals = FALSE) | |
| c$legend(enabled=FALSE) | |
| c$chart(height=200) | |
| c$tooltip(useHTML = T, formatter = "#! function() { return this.point.info; } !#") | |
| c$set(dom = 'posChart') | |
| return(c) | |
| }) | |
| }) | |
| # Home team lineup | |
| output$home <- renderTable({ | |
| print("matchid") | |
| print(input$info$MATCHID) | |
| if (is.null(input$info$MATCHID)){ | |
| matchid_chosen = 1313 | |
| } else { | |
| matchid_chosen = input$info$MATCHID | |
| } | |
| df <- subset(Lineups, MATCHID==matchid_chosen&venue=="H") | |
| df$order <- 1 | |
| df[str_sub(df$POSITION,1,1)=="D",]$order <- 2 | |
| df[str_sub(df$POSITION,1,1)=="M",]$order <- 3 | |
| df[str_sub(df$POSITION,1,1)=="F",]$order <- 4 | |
| for (i in 1:nrow(df)) { | |
| if (is.na(df$CARD[i])) { | |
| df$C[i] <- '' | |
| } else if (df$CARD[i]=="Y") { | |
| df$C[i] <- '<img src="http://guardian.touch-line.com/images/yellow.gif"></img>' | |
| } else if (df$CARD[i]=="R") { | |
| df$C[i] <- '<img src="http://guardian.touch-line.com/images/red.gif"></img>' | |
| } else if (df$CARD[i]=="P") { | |
| df$C[i] <-'<img src="http://guardian.touch-line.com/images/yellow.gif"> </img><img src="http://guardian.touch-line.com/images/yellow.gif"></img>' | |
| } else if (df$CARD[i]=="Z"||df$CARD[i]=="X") { | |
| df$C[i] <-'<img src="http://guardian.touch-line.com/images/yellow.gif"> </img><img src="http://guardian.touch-line.com/images/red.gif"></img>' | |
| } | |
| } | |
| df$sub <- '' | |
| df <- arrange(df,desc(START),order,LASTNAME) # might want to change for older games where not all starts are 3 or change in lineus probeasier make all 6 | |
| df$name <- paste0(df$LASTNAME,", ",str_sub(df$FIRSTNAME,1,1)) | |
| df[df$Goals<1,]$Goals <- NA | |
| colnames(df)[8] <- "G" | |
| colnames(df)[21] <- "A" | |
| df$nameInfo <- df$name | |
| # sub image | |
| df$S <-'' | |
| for (i in 1:nrow(df)) { | |
| if (df$subOn[i]>0&df$OFF[i]==0) { | |
| df$nameInfo[i] <- paste0(df$name[i]," (",df$subOn[i],")") | |
| df$S[i] <- '<img src="http://guardian.touch-line.com/images/MatchSubs/on1.gif"></img>' | |
| } else if (df$subOn[i]==0&df$OFF[i]>0) { | |
| df$nameInfo[i] <- paste0(df$name[i]," (",df$OFF[i],")") | |
| df$S[i] <- '<img src="http://guardian.touch-line.com/images/MatchSubs/off1.gif"></img>' | |
| } else if (df$subOn[i]>0&df$OFF[i]>0) { | |
| df$nameInfo[i] <- paste0(df$name[i]," (",df$subOn[i],", ",df$OFF[i],")") | |
| } | |
| } | |
| # birth country flag - still ned to setup | |
| for (i in 1:nrow(df)) { | |
| if (!is.na(df$iso2c[i])) { | |
| df$B[i] <- paste0('<img src="images/gif/',df$iso2c[i],'.gif" title="',df$COUNTRY[i],'"></img>') | |
| } else { | |
| df$B[i] <- "" # should add dummy flag | |
| } | |
| } | |
| # Age | |
| df$BIRTHDATE <- ymd(df$BIRTHDATE) # makes POSIXct | |
| df$gameDate <- ymd(df$gameDate) | |
| df$Age <- str_sub(as.period(df$gameDate - df$BIRTHDATE, units = "year"),1,2) | |
| df_print<- data.frame(df[,c("B","Age","nameInfo","S","G","A","C")]) | |
| colnames(df_print) <- c("","","","","Gl","As","Cd") | |
| df_print | |
| }, include.rownames=FALSE, sanitize.text.function = function(x) x) | |
| output$homeText <- renderText({ | |
| unique(subset(Lineups, MATCHID==8041&venue=="H")$TEAMNAME) | |
| }) | |
| output$away <- renderTable({ | |
| if (is.null(input$info$ | |
| MATCHID)){ | |
| matchid_chosen = 1313 | |
| } else { | |
| matchid_chosen = input$info$MATCHID | |
| } | |
| df <- subset(Lineups, MATCHID==matchid_chosen&venue=="A") | |
| df$order <- 1 | |
| df[str_sub(df$POSITION,1,1)=="D",]$order <- 2 | |
| df[str_sub(df$POSITION,1,1)=="M",]$order <- 3 | |
| df[str_sub(df$POSITION,1,1)=="F",]$order <- 4 | |
| for (i in 1:nrow(df)) { | |
| if (is.na(df$CARD[i])) { | |
| df$C[i] <- '' | |
| } else if (df$CARD[i]=="Y") { | |
| df$C[i] <- '<img src="http://guardian.touch-line.com/images/yellow.gif"></img>' | |
| } else if (df$CARD[i]=="R") { | |
| df$C[i] <- '<img src="http://guardian.touch-line.com/images/red.gif"></img>' | |
| } else if (df$CARD[i]=="P") { | |
| df$C[i] <-'<img src="http://guardian.touch-line.com/images/yellow.gif"> </img><img src="http://guardian.touch-line.com/images/yellow.gif"></img>' | |
| } else if (df$CARD[i]=="Z"||df$CARD[i]=="X") { | |
| df$C[i] <-'<img src="http://guardian.touch-line.com/images/yellow.gif"> </img><img src="http://guardian.touch-line.com/images/red.gif"></img>' | |
| } | |
| } | |
| df$sub <- '' | |
| df <- arrange(df,desc(START),order,LASTNAME) # might want to change for older games where not all starts are 3 or change in lineus probeasier make all 6 | |
| df$name <- paste0(df$LASTNAME,", ",str_sub(df$FIRSTNAME,1,1)) | |
| df[df$Goals<1,]$Goals <- NA | |
| colnames(df)[8] <- "G" | |
| colnames(df)[21] <- "A" | |
| df$nameInfo <- df$name | |
| # sub image | |
| df$S <-'' | |
| for (i in 1:nrow(df)) { | |
| if (df$subOn[i]>0&df$OFF[i]==0) { | |
| df$nameInfo[i] <- paste0(df$name[i]," (",df$subOn[i],")") | |
| df$S[i] <- '<img src="http://guardian.touch-line.com/images/MatchSubs/on1.gif"></img>' | |
| } else if (df$subOn[i]==0&df$OFF[i]>0) { | |
| df$nameInfo[i] <- paste0(df$name[i]," (",df$OFF[i],")") | |
| df$S[i] <- '<img src="http://guardian.touch-line.com/images/MatchSubs/off1.gif"></img>' | |
| } else if (df$subOn[i]>0&df$OFF[i]>0) { | |
| df$nameInfo[i] <- paste0(df$name[i]," (",df$subOn[i],", ",df$OFF[i],")") | |
| } | |
| } | |
| # df$Country <- "england" # obv will vary when got sorted | |
| # birth country flag - still ned to setup | |
| for (i in 1:nrow(df)) { | |
| if (!is.na(df$iso2c[i])) { | |
| df$B[i] <- paste0('<img src="images/gif/',df$iso2c[i],'.gif" title="',df$COUNTRY[i],'"></img>') | |
| } else { | |
| df$B[i] <- "" # should add dummy flag | |
| } | |
| } | |
| # Age | |
| df$BIRTHDATE <- ymd(df$BIRTHDATE) # makes POSIXct | |
| df$gameDate <- ymd(df$gameDate) | |
| df$Age <- str_sub(as.period(df$gameDate - df$BIRTHDATE, units = "year"),1,2) | |
| df_print<- data.frame(df[,c("B","Age","nameInfo","S","G","A","C")]) | |
| colnames(df_print) <- c("","","","","Gl","As","Cd") | |
| df_print | |
| }, include.rownames=FALSE, sanitize.text.function = function(x) x) | |
| output$homeText <- renderText({ | |
| unique(subset(Lineups, MATCHID==8041&venue=="H")$TEAMNAME) | |
| }) | |
| output$homeBadge <- renderUI({ | |
| img(src="http://images.racingpost.com/football/teambadges/2471.png", width="20", height="20") #works | |
| # try to combine image and text alts with css not working either yet | |
| #paste(img(src="http://images.racingpost.com/football/teambadges/2471.png", width="20", height="20")) # makes text | |
| }) | |
| output$homeText <- renderText({ | |
| output$homeText <- renderText({ | |
| if (is.null(input$info$MATCHID)){ | |
| matchid_chosen = 1313 | |
| } else { | |
| matchid_chosen = input$info$MATCHID | |
| } | |
| unique(subset(Lineups, MATCHID==matchid_chosen&venue=="H")$TEAMNAME) | |
| }) | |
| }) | |
| output$description <- renderText({ | |
| repURL <- "http://www.guardian.co.uk/football/2013/may/19/tottenham-sunderland-premier-league-match-report" | |
| basicInfo <- htmlParse(repURL, isURL = TRUE) | |
| description <-xpathSApply(basicInfo, '//*/meta[@name="description"]/@content') | |
| title <- xpathSApply(basicInfo, '//*/meta[@property="og:title"]/@content') | |
| title_df <- data.frame(title) | |
| title <- as.character(title_df$title[1]) | |
| d_df <- data.frame(description) | |
| description<- as.character(d_df$description[1]) | |
| description | |
| }) | |
| output$report <- renderText({ | |
| repURL <- "http://www.guardian.co.uk/football/2013/may/19/tottenham-sunderland-premier-league-match-report" | |
| basicInfo <- htmlParse(repURL, isURL = TRUE) | |
| content <- xpathSApply(basicInfo, "//*/p/text()", xmlValue)[2] | |
| x <- unlist(strsplit(content, "\\s+")) | |
| y <- split(x, seq_along(x)%/%150) | |
| content <- paste(y[[1]],collapse=' ') # then add more... wih a href | |
| content | |
| }) | |
| }) |
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
| season | team | seasonGame | Pos | seasonGame.1 | W | D | L | totGF | totGA | totGD | cumPoints | gameDate | venue | result | GF | GA | GD | points | maxGame | finalPos | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1992/1993 | Arsenal | 6 | 6 | 6 | 3 | 1 | 2 | 8 | 6 | 2 | 10 | 1992-09-02 | A | D | 0 | 0 | 0 | 1 | 42 | 10 | |
| 1992/1993 | Arsenal | 1 | 22 | 1 | 0 | 0 | 1 | 2 | 4 | -2 | 0 | 1992-08-15 | H | L | 2 | 4 | -2 | 0 | 42 | 10 | |
| 1992/1993 | Arsenal | 3 | 14 | 3 | 1 | 0 | 2 | 4 | 5 | -1 | 3 | 1992-08-23 | A | W | 2 | 0 | 2 | 3 | 42 | 10 |
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
| shinyUI(pageWithSidebar( | |
| # Application title. Leave blank to create more space | |
| headerPanel(""), | |
| sidebarPanel( | |
| tags$head( | |
| tags$link(rel = 'stylesheet', type = 'text/css', href = 'styles.css')), | |
| helpText(h5 | |
| (p("Results, interaction standing"))), | |
| wellPanel( | |
| selectInput("season", "Select Season",seasonChoice), | |
| uiOutput("teams"), | |
| actionButton("goButton","Refresh") | |
| ), | |
| h5(textOutput("description")), | |
| p(textOutput("report")) | |
| ), | |
| mainPanel( | |
| showOutput("posChart","highcharts"), | |
| showOutput("myChart","highcharts"), | |
| uiOutput("homeBadge"), textOutput("homeText"), | |
| div(class="row"), | |
| div(class="span5", tableOutput("home")), | |
| div(class="span5", tableOutput("away")) | |
| ) | |
| )) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment