Skip to content

Instantly share code, notes, and snippets.

View pssguy's full-sized avatar

Andrew Clark pssguy

View GitHub Profile
@pssguy
pssguy / global.R
Created November 15, 2012 21:01
Shiny example: EPL Players Goal Scoring Runs
library(shiny)
library(ggplot2)
# data based on goals scored to early November 2012
url <- "http://www.premiersoccerstats.com/plScoringRuns.csv"
df <- read.csv(url,stringsAsFactors=FALSE)
# create the data for the selectInput
playerChoices <- unique(df[,c(1,2)])$PLAYERID
@pssguy
pssguy / global.R
Created November 16, 2012 00:40
Shiny App showing graphs of goal methods for all EPL players with more than 50 career goals
# My first tiny-shiny
# Thanks to all the guys at R-Studio, especially Joe Cheng for some hand-holding
# The global.r script can hold variables available to both ui.r and server.R
library(shiny)
library(ggplot2)
# data based on goals scored to early November 2012
df <- read.csv("http://www.premiersoccerstats.com/shinyGoals.csv",stringsAsFactors=FALSE)
@pssguy
pssguy / server.R
Created November 29, 2012 20:37
Shiny App allowing online selection of subjects for graphical and tabular presentation of daily Wikipedia search rates
# libraries used. install as necessary
library(shiny)
library(RJSONIO) # acquiring and parsing data
library(ggplot2) # graphs
library(plyr) # manipulating data
library(lubridate) #dates
library(stringr)
trim.leading <- function (x) sub("^\\s+", "", x)
@pssguy
pssguy / global.R
Created December 4, 2012 22:39
Shint App mapping earthquakes by magnitude, country and year
library(maps)
library(shiny)
library(stringr)
worlddf <- map("world")
# restrict selection to coutries only
locations <- worlddf$names
countries <-subset(locations,is.na(str_locate(locations,":")))
@pssguy
pssguy / global.R
Last active January 21, 2018 01:25
Motion Chart of Premier League Positions by game for past 20+ seasons. Shiny app using googleVis package The data is not currently provided but to-date charts can be viewed at glimmer.rstudio.com/pssguy/eplTableMotion/
# load requisite libraries
library(shiny)
library(googleVis)
# load raw data (NB not provided)
tableByGame <- read.csv("../tableByGame.csv",stringsAsFactors=FALSE)
# to create chart need to repeat one column and get negative of league position as hack
tableByGame$game <- tableByGame$seasonGame
tableByGame$lgPos <- -tableByGame$lgPos
@pssguy
pssguy / global.R
Created March 19, 2013 19:06
Upload Example in Shiny App. Takes Pupil's term marks and does some analyses
# load required libraries
library(shiny)
library(plyr)
library(ggplot2)
library(googleVis)
library(reshape2)
####creation of example data on local directory for uploading####
@pssguy
pssguy / global.R
Created May 1, 2013 21:14
Shiny App showing ranking of 140+ TV Shows by episode
# load required packages
library(shiny)
library(shinyIncubator)
library(googleVis)
library(ggplot2)
library(stringr)
library(plyr)
library(XML)
library(httr)
library(Hmisc)
@pssguy
pssguy / global.R
Last active December 18, 2015 08:09 — forked from sckott/server.r
library(shiny)
library(shinyIncubator)
library(rbison)
library(rjson)
library(taxize)
library(plyr)
library(googleVis)
library(XML)
library(stringr)
@pssguy
pssguy / bestRank.csv
Last active December 18, 2015 19:29
Provides plots and tables based on the packages downloaded from the RStudio CRAN mirror. It is a Shiny App using rCharts so users can specify packages, countries and weeks of interest them and get interactive charts with tooltips and clickable links to package pdfs. The gist utilizes a limited amout of data. The production App can be viewed at h…
package mostDownloads bestRank week tot rank
shiny 1018 70 2013-06-10 1018 70
RColorBrewer 4376 4 2013-04-29 3408 4
scales 3976 6 2012-12-10 1571 6
scales 3976 6 2012-12-03 1720 6
reshape2 4330 6 2012-12-17 1312 6
reshape2 4330 6 2013-01-07 2199 6
reshape2 4330 6 2013-05-13 3660 6
proto 3902 3 2012-12-24 963 3
ggplot2 5291 1 2013-03-25 3160 1
@pssguy
pssguy / Lineups.csv
Last active December 19, 2015 00:29
Test. EPL charts and lineups
We can make this file beautiful and searchable if this error is corrected: Unclosed quoted field in line 7.
"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","AR