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 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 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 / 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 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 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 / test.rmd
Created March 10, 2016 17:08
R markDowntest for JJ Allaire
---
title: "Sometimes I do not want to see this"
author: "mytinyshinys"
date: "March 4, 2016"
output:
html_document:
fig_caption: yes
theme: flatly
toc: true
toc_float: true
@pssguy
pssguy / server.R
Created December 20, 2013 22:00
Shiny Nvigation Test
shinyServer(function(input, output, session) {
## code for Distribution option
output$distPlot <- renderPlot({
# generate an rnorm distribution and plot it
dist <- rnorm(input$obs)
hist(dist)
})
@pssguy
pssguy / server.R
Last active December 20, 2015 11:49
Nested tabsets
require(shiny)
shinyServer(function(input, output, session) {
})
@pssguy
pssguy / global.R
Last active December 20, 2015 10:39
simple dataTabls setup
require(shiny)
require(rCharts)
names<- letters
numbers <- 1:26
dates <- rep(as.Date(c("2010-01-01","2011-07-23","2011-01-03")),8)
dates <- c(dates,as.Date(c("1999-12-25", "2005-07-13")))
df <- data.frame(names=names,numbers=numbers,dates=dates)
@pssguy
pssguy / charts.R
Created July 25, 2013 17:37
Attempt to combine 2 highcharts
area <- rCharts:::Highcharts$new()
area$series(data = toJSONArray2(valdf, json = F, names = F),type = "area", name="Points")
area$yAxis(title=list(text="Points"),opposite=TRUE)
area$xAxis(labels=list(enabled=FALSE))
area$plotOptions(area = list(marker = list(enabled = FALSE,symbol = "circle", radius = 2)))
area$chart(zoomType="xy")
area$title(text="World Ranking")
area$subtitle(text="Zoom for closer look")
area$chart(height=300)
area