Skip to content

Instantly share code, notes, and snippets.

View jalapic's full-sized avatar

James Curley jalapic

View GitHub Profile
@jalapic
jalapic / index.html
Created August 28, 2015 22:18
Stop and Frisk NYC 2014
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Loading Stop and Frisk CSV Data with D3</title>
<script type="text/javascript" src="http://d3js.org/d3.v3.js"></script>
</head>
<body>
<p>Here are the Stop and Frisk Data for NYC 2014</p>
@jalapic
jalapic / bdays
Created June 15, 2014 22:35
World Cup Player Birthdays
### Extracting Squads
library(XML)
doc <- readHTMLTable(doc="http://en.wikipedia.org/wiki/2014_FIFA_World_Cup_squads", header=TRUE)
#put the countries into a list
#had to manually check the correct doc to use for each country
l<-list(doc[[2]], doc[[4]],doc[[6]], doc[[8]],doc[[10]], doc[[12]],doc[[14]], doc[[16]],doc[[18]], doc[[20]],
doc[[22]], doc[[24]],doc[[26]], doc[[28]],doc[[30]], doc[[32]],doc[[34]], doc[[36]],doc[[38]], doc[[40]],
doc[[42]], doc[[44]],doc[[46]], doc[[48]],doc[[50]], doc[[52]],doc[[54]], doc[[56]],doc[[58]], doc[[60]],
doc[[62]], doc[[64]])
#### Anscombe's Quartet
temp <-
data.frame( x1 = c(10, 8, 13, 9, 11, 14, 6, 4, 12, 7, 5),
y1 = c(8.04, 6.95, 7.58, 8.81, 8.33, 9.96, 7.24, 4.26, 10.84, 4.82, 5.68),
x2 = c(10, 8, 13, 9, 11, 14, 6, 4, 12, 7, 5),
y2 = c(9.14, 8.14, 8.74, 8.77, 9.26, 8.1, 6.13, 3.1, 9.13, 7.26, 4.74),
x3 = c(10, 8, 13, 9, 11, 14, 6, 4, 12, 7, 5),
y3 = c(7.46, 6.77, 12.74, 7.11, 7.81, 8.84, 6.08, 5.39, 8.15, 6.42, 5.73),
x4 = c(8, 8, 8, 8, 8, 8, 8, 19, 8, 8, 8),
### Quick illustration of dplyr / ggplot2
library(dplyr)
library(ggplot2)
library(magrittr)
# Install babynames package
install.packages("babynames")
# load library
### Using tsne to map similarity of English Soccer Teams
library(engsoccerdata)
library(dplyr)
library(magrittr)
library(ggplot2)
library(tidyr)
library(tsne)
@jalapic
jalapic / onetrain
Last active August 29, 2015 14:15
library(DiagrammeR)
#import onetrain data
head(onetrain)
edges <- onetrain
edges #edges.minlen doesn't seem to do much in final viz
# Create a 'nodes' data frame
### Bar plots in ggplot
# data come from engsoccerdata package.
#### bar plot
library(ggplot2)
ggplot(df, aes(Season, totalpts, fill= country)) +
geom_bar(position="dodge", stat="identity") +
### Permutation Test Example... #based on: http://spark.rstudio.com/ahmed/permutation/
# Group A
a = c(86, 88, 89, 89, 92, 93, 94, 94, 94, 95, 95, 96, 96, 97, 97, 98, 98, 99, 99, 101, 106, 107, 110, 113, 116, 118)
# Group B
b = c(89, 90, 92, 93, 93, 96, 99, 99, 99, 102, 103, 104, 105, 106, 106, 107, 108, 108, 110, 110, 112, 114, 116, 116)
df <-
library(shiny)
library(sortableR)
library(ggplot2)
ui = shinyUI(fluidPage(
fluidRow(
column( width = 4
,tags$h4("sortableR in Shiny - Moving widgets")
,tags$div(id="veryUniqueId", class="list-group"
,tags$div(class="list-group-item", sliderInput("slider", "Slide me:", min = 10, max = 500, value = 275))
## app.R ##
library(shiny)
library(shinydashboard)
library(sortableR)
ui <- dashboardPage(
dashboardHeader(disable = TRUE),
dashboardSidebar(disable = TRUE),
dashboardBody(