This file contains 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
library(shiny) | |
library(ggvis) | |
shinyServer(function(input, output, session) { | |
df <- mtcars | |
df$id <- 1:nrow(df) | |
plot_data <- reactive({ | |
df$x <- df[,input$x_var] |
This file contains 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
library(shiny) | |
library(ggvis) | |
shinyServer(function(input, output, session) { | |
df <- mtcars | |
plot_data <- reactive({ | |
df$x <- df[,input$x_var] |
This file contains 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
library(shiny) | |
library(ggmap) | |
shinyServer(function(input, output) { | |
output$chicagoPlot <- renderPlot({ | |
p <- qmap("chicago IL") | |
print(p) | |
}) |
This file contains 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
library(ggvis) | |
shinyServer(function(input, output, session) { | |
mtcars <- cbind(mtcars, id = seq_len(nrow(mtcars))) | |
# Create a linked brush object | |
lb <- linked_brush(keys = mtcars$id, "red") | |
# Just the brushed points | |
selected <- lb$selected |
This file contains 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
library(rCharts) | |
bus.map <- Leaflet$new() | |
bus.map$setView(c(40.4739, -88.9719), zoom = 13) | |
bus.map$tileLayer(provider = 'Stamen.TonerLite') | |
# Add Data as GeoJSON Layer and Specify Popup and FillColor | |
bus.map$geoJson(toGeoJSON(tmp.data, lat = 'lat', lon = 'lon'), | |
onEachFeature = '#! function(feature, layer){ | |
layer.bindPopup(feature.properties.popup) | |
} !#', | |
pointToLayer = "#! function(feature, latlng){ |
This file contains 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
library(RColorBrewer) | |
# max of 12 cats in colorbrewer, gotta add 6 more | |
colors <- brewer.pal(12, "Paired") | |
colors <- c(colors, "#050505", "#FAF20F", "#FA28EC", "#24E3CD", "#DAFAD4", "#6B6C6E") | |
df2 <- df | |
routes <- unique(df2$route) | |
df2$color <- colors[match(df2$route, routes)] | |
df2$popup <- paste0("<p>Pick up time: ", df$pu.time, | |
"<br>Drop off time: ", df$do.time, | |
"<br>", df$stop, |
This file contains 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
> head(df) | |
route od pu.time do.time | |
3 BHS_11.pdf 6:54 AM RAINBOW AVE @ RIDGEPORT AVE 2:33 PM 6:54 AM 2:33 PM | |
4 BHS_11.pdf 7:02 AM RIDGEPORT AVE @ CLEARWATER AVE 2:36 PM 7:02 AM 2:36 PM | |
8 BHS_13.pdf 6:48 AM ON MERCER AT LINCOLN 2:44 PM 6:48 AM 2:44 PM | |
10 BHS_13.pdf 6:49 AM BENJAMIN LN @ SNYDER DR 2:46 PM 6:49 AM 2:46 PM | |
11 BHS_13.pdf 6:52 AM ON ARCADIA AT FAIRMONT 2:33 PM 6:52 AM 2:33 PM | |
13 BHS_13.pdf 6:55 AM BROADMOOR DR @ PHEASANT RUN 2:35 PM 6:55 AM 2:35 PM | |
stop lat lon | |
3 RAINBOW AVE and RIDGEPORT AVE 40.49903 -88.94384 |
This file contains 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
library(tm) | |
pdf <- readPDF(PdftotextOptions = "-layout") | |
dat <- pdf(elem = list(uri=paste0("data/", file)), language='en', id='id1') | |
dat <- gsub(' +', ',', dat) | |
out <- read.csv(textConnection(dat), header=FALSE) | |
out <- apply(out, 1, function(x)paste(x, collapse=" ")) |
This file contains 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
library(downloader) | |
for(link in links){ | |
url1 <- paste0("http://www.district87.org", link) | |
download(url1, file.path("data", basename(url1))) | |
} |
This file contains 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
library(XML) | |
library(httr) | |
url1 <- "http://www.district87.org/pages/Bloomington_School_District_87/Parents_and_Students/Bus_Routes/Bloomington_High_School" | |
x <- GET(url1) | |
text <- content(x, as="text") | |
doc <- htmlParse(text) | |
a <- xpathSApply(doc, "//table[@id='fsvItemsTable']/tr") | |
links <- xpathSApply(a[[1]], "//a/@href") | |
links <- links[grepl("^/files", links)] |