Skip to content

Instantly share code, notes, and snippets.

View mndrake's full-sized avatar
🏠
Working from home

David Carlson mndrake

🏠
Working from home
View GitHub Profile
@mndrake
mndrake / shiny_leaflet_brushing.R
Created March 29, 2017 00:39
Interactive Polygon Brushing with Shiny and Leaflet
# originally from: http://stackoverflow.com/questions/42528400/plot-brushing-or-accessing-drawn-shape-geometry-for-spatial-subsets-in-shiny-lea
# uses https://github.com/bhaskarvk/leaflet.extras
library(shiny)
library(leaflet)
library(leaflet.extras)
library(sp)
cities <- structure(list(AccentCity = c("Saint Petersburg", "Harare", "Qingdao",
"Addis Abeba", "Xian", "Anshan", "Rongcheng", "Kinshasa", "New York",
library(shiny)
shinyServer(function(input, output, session) {
# Return the components of the URL in a string:
output$urlText <- renderText({
paste(sep = "",
"protocol: ", session$clientData$url_protocol, "\n",
"hostname: ", session$clientData$url_hostname, "\n",
"pathname: ", session$clientData$url_pathname, "\n",
@mndrake
mndrake / dplyr_sql_extension.R
Last active August 24, 2016 00:26
extension methods for dplyr remote tables
library(dplyr)
library(nycflights13)
conn <- nycflights13_sqlite()
flights_sql <- tbl(conn, 'flights')
weather_sql <- tbl(conn, 'weather')
`[.tbl_sql` <- function(x, condition) {
x %>% select_(condition)
}
library(xgboost)
library(Matrix)
library(data.table)
library(caret)
source('gini.R')
df <- read.csv('data/train.csv')
df.matrix <- model.matrix(Hazard~.-1,df)
set.seed(107)
@mndrake
mndrake / install.R
Created August 11, 2015 19:37
h2o domino
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Install h2o
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# The following two commands remove any previously installed H2O packages for R.
if ("package:h2o" %in% search()) { detach("package:h2o", unload=TRUE) }
if ("h2o" %in% rownames(installed.packages())) { remove.packages("h2o") }
# Next, we download packages that H2O depends on.
if (! ("methods" %in% rownames(installed.packages()))) { install.packages("methods") }
@mndrake
mndrake / charting_example.ipynb
Created June 29, 2015 12:54
charting example using IfSharp
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mndrake
mndrake / dc_boxplot.ipynb
Created February 9, 2015 17:31
dc.js boxplot example in ifsharp notebook
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mndrake
mndrake / metricsgraphics.ipynb
Last active August 29, 2015 14:14
metricsgraphics.js wrapper for ifsharp
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mndrake
mndrake / nvd3_charting.ipynb
Created February 3, 2015 12:04
proof of concept wrapper of NVD3.js for IfSharp
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mndrake
mndrake / ifsharp_nvd3_2.ipynb
Created February 2, 2015 03:33
nvd3 attempt using require.js
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.