Skip to content

Instantly share code, notes, and snippets.

@hafen
hafen / README.md
Created February 4, 2016 07:27
NYC bikes 2
gmap(lat = 40.73306, lng = -73.97351, zoom = 12,
  width = 680, height = 600, map_type = "roadmap") %>%
  ly_points(lon, lat, data = bike, hover = c(station, n_start, n_end))
@hafen
hafen / README.md
Created February 4, 2016 08:03
NYC bikes 3
gmap(lat = 40.73306, lng = -73.97351, zoom = 12,
  width = 680, height = 600,
  map_style = gmap_style("blue_water")) %>%
  ly_points(lon, lat, data = bike, hover = c(station, n_start, n_end))
@hafen
hafen / README.md
Created February 4, 2016 08:03
NYC bikes 4
style <- '[{"featureType":"administrative","elementType":"all","stylers":[{"hue":"#ffffff"},{"lightness":100},{"visibility":"off"}]},{"featureType":"landscape","elementType":"all","stylers":[{"hue":"#ffffff"},{"saturation":-100},{"lightness":100},{"visibility":"on"}]},{"featureType":"poi","elementType":"all","stylers":[{"hue":"#ffffff"},{"saturation":-100},{"lightness":100},{"visibility":"off"}]},{"featureType":"road","elementType":"geometry","stylers":[{"hue":"#000000"},{"saturation":-100},{"lightness":-100},{"visibility":"simplified"}]},{"featureType":"road","elementType":"labels","stylers":[{"hue":"#ffffff"},{"saturation":-100},{"lightness":100},{"visibility":"off"}]},{"featureType":"transit","elementType":"geometry","stylers":[{"hue":"#000000"},{"lightness":-100},{"visibility":"on"}]},{"featureType":"transit","elementType":"labels","stylers":[{"hue":"#ffffff"},{"lightness":100},{"visibility":"off"}]},{"featureType":"water","elementType":"all","stylers":[{"hue":"#ffffff"},{"saturation":-100},{"light
@hafen
hafen / README.md
Created February 4, 2016 08:05
NYC bikes 5
cdist <- read.csv("https://gist.githubusercontent.com/hafen/a447521ff8b24ddefba5/raw/044e174d7b9e6a370fff429f9cda4d0903b4c0a6/communitydistricts.csv")

bike$diff <- bike$n_start - bike$n_end
bike$color = ifelse(bike$diff > 0, "#2CA02C", "#D62728")

gmap(lat = 40.73306, lng = -73.97351, zoom = 12,
 width = 680, height = 600, map_style = gmap_style("blue_water")) %&gt;%
@hafen
hafen / rbokeh-shiny-callback.R
Created February 4, 2016 20:19
rbokeh shiny callback experiment
# devtools::install_github("bokeh/rbokeh@dev")
library("shiny")
library("rbokeh")
dat <- data.frame(x = rnorm(10), y = rnorm(10))
ui <- fluidPage(
rbokehOutput("rbokeh", width = 500, height = 540),
strong("x range change event:"),
@hafen
hafen / README.md
Created February 4, 2016 20:27
rbokeh callback test
dat <- data.frame(x = runif(500), y = runif(500))

p <- figure(title = "select points to adjust mean line",
  tools = "lasso_select") %>%
  ly_points(x, y, data = dat, lname = "points") %>%
  ly_lines(x = c(0, 1), y = rep(mean(dat$y), 2), line_width = 6,
 color = "orange", alpha = 0.75, lname = "mean")
@hafen
hafen / README.md
Created February 4, 2016 20:30
rbokeh callback test 2
D <- data.frame(
  x = c(2, 3, 5, 6, 8, 7),
  y = c(6, 4, 3, 8, 7, 5))

links <- list(
  "0" = c(1, 2),
  "1" = c(0, 3, 4),
@hafen
hafen / data.R
Last active June 18, 2017 09:57
scatterplot data
"x","y","f1","f2"
-1.20706574938542,-1.81689753163211,"d1",-1
0.27742924211066,0.627166843904992,"d1",3
1.08444117668306,0.518092102643454,"d1",3
-2.34569770262935,0.140921830082034,"d1",-3
0.42912468881105,1.45727194611984,"d1",3
0.506055892157574,-0.49359652203013,"d1",1
-0.574739960134649,-2.12224406186793,"d1",-1
-0.546631855784187,-0.133566601258707,"d1",-1
-0.564451999093283,-0.427600353483175,"d1",-1
@hafen
hafen / README.md
Created February 5, 2016 00:52
scatter
figure() %>%
  ly_points(x, y, data = dat)
@hafen
hafen / README.md
Created February 5, 2016 00:53
scatter with lod
figure(lod_threshold = 100) %>%
  ly_points(x, y, data = dat)