Skip to content

Instantly share code, notes, and snippets.

View mkfreeman's full-sized avatar

Michael Freeman mkfreeman

View GitHub Profile
@mkfreeman
mkfreeman / format_data.R
Created April 27, 2020 16:38
Government-mandated social distancing by location and date (with all dates)
library(tidyverse)
data <- read.csv('https://gist.githubusercontent.com/aflaxman/e93187b6a0845358dfca2c44e2492ee4/raw/347ce1ab6b18a011dd6bedb0cdb04b9bd0a68e7d/sdc_sources.csv', stringsAsFactors = F)
data <- data %>%
mutate(Initial.business.closures = if_else(
Initial.business.closures == "full implementation", # If it's "full ..."
Non.essential.services.closed, # Set as non essential
Initial.business.closures)) %>% # Otherwise keep it
mutate(Mass.gathering.restrictions = if_else(
Mass.gathering.restrictions == "full implementation", # If it's "full ..."
Stay.at.Home.Order, # Set as Stay at home
We can make this file beautiful and searchable if this error is corrected: It looks like row 4 should actually have 33 columns, instead of 6. in line 3.
mean_radius,mean_texture,mean_perimeter,mean_area,mean_smoothness,mean_compactness,mean_concavity,mean_concave_points,mean_symmetry,mean_fractal_dimension,radius_error,texture_error,perimeter_error,area_error,smoothness_error,compactness_error,concavity_error,concave_points_error,symmetry_error,fractal_dimension_error,worst_radius,worst_texture,worst_perimeter,worst_area,worst_smoothness,worst_compactness,worst_concavity,worst_concave_points,worst_symmetry,worst_fractal_dimension,outcome,logistic_preds,binary_preds
17.99,10.38,122.8,1001.0,0.1184,0.2776,0.3001,0.1471,0.2419,0.07871,1.095,0.9053,8.589,153.4,0.006399,0.04904,0.05373,0.01587,0.03003,0.006193,25.38,17.33,184.6,2019.0,0.1622,0.6656,0.7119,0.2654,0.4601,0.1189,1,0.9997388288733227,1
20.57,17.77,132.9,1326.0,0.08474,0.07864,0.0869,0.07017,0.1812,0.05667,0.5435,0.7339,3.398,74.08,0.005225,0.01308,0.0186,0.0134,0.01389,0.003532,24.99,23.41,158.8,1956.0,0.1238,0.1866,0.2416,0.186,0.275,0.08902,1,0.9648224102617772,1
19.69,21.25,130.0,1203.0,0.1096,0.15
@mkfreeman
mkfreeman / data.csv
Created November 9, 2019 15:52
cancer_data
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
mean_radius mean_texture mean_perimeter mean_area mean_smoothness mean_compactness mean_concavity mean_concave_points mean_symmetry mean_fractal_dimension radius_error texture_error perimeter_error area_error smoothness_error compactness_error concavity_error concave_points_error symmetry_error fractal_dimension_error worst_radius worst_texture worst_perimeter worst_area worst_smoothness worst_compactness worst_concavity worst_concave_points worst_symmetry worst_fractal_dimension outcome logistic_preds binary_preds
17.99 10.38 122.8 1001 0.1184 0.2776 0.3001 0.1471 0.2419 0.07871 1.095 0.9053 8.589 153.4 0.006399 0.04904 0.05373 0.01587 0.03003 0.006193 25.38 17.33 184.6 2019 0.1622 0.6656 0.7119 0.2654 0.4601 0.1189 1 0.999738829 1
20.57 17.77 132.9 1326 0.08474 0.07864 0.0869 0.07017 0.1812 0.05667 0.5435 0.7339 3.398 74.08 0.005225 0.01308 0.0186 0.0134 0.01389 0.003532 24.99 23.41 158.8 1956 0.1238 0.1866 0.2416 0.186 0.275 0.08902 1 0.96482241 1
19.69 21.25 130 1203 0.1096 0.1599 0.1974 0.1279 0.2069 0.0
@mkfreeman
mkfreeman / index.html
Created October 17, 2017 06:03 — forked from d3noob/index.html
Sankey Diagram with v4
<!DOCTYPE html>
<meta charset="utf-8">
<title>SANKEY Experiment</title>
<style>
.node rect {
cursor: move;
fill-opacity: .9;
shape-rendering: crispEdges;
}
@mkfreeman
mkfreeman / Readme.md
Last active June 29, 2016 11:52
Gooey effect - Hexagon (with React, not D3.js)

Attempted to recreate the amazing work of Nadieh Bremmer to see how to start using React with D3.js. Ended up not using D3.js at all! The pointInPolygon function doesn't work perfectly (obviously). Comments/feedback are welcome via Gist or twitter.

// Histogram adapted from https://bl.ocks.org/mbostock/3048450
// On load, append chart element
$(function() {
// Select SVG to work with, setting width and height (the vis <div> is defined in the index.html file)
var svg = d3.select('#vis')
.append('svg')
.attr('height', 350)
.attr('width', 900);
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
<style id="jsbin-css">
#{
}
</style>
</head>
@mkfreeman
mkfreeman / gist:fedb518953b94efae3b0
Created March 18, 2015 01:36
Test route station data
# Station test
library(plyr)
library(data.table)
routes <- read.csv('/Users/michaelfreeman/Downloads/Divvy_RouteShapes_ALL-FINAL.csv')
route_stations <- count(routes, c('stationFromId', 'stationFromLat', 'stationFromLong'))
setnames(route_stations, 'stationFromId', 'id')
setwd('/Applications/MAMP/htdocs/divvy-munging/data_from_divvy/2014/Divvy_Stations_Trips_2014_Q3Q4')
station_locations <- read.csv('Divvy_Stations_2014-Q3Q4.csv')
mergeData <- merge(station_locations, route_stations, by=c('id'))
plot(mergeData$latitude, mergeData$stationFromLat)
error: Error running command deploy
error: Errors occured while starting the application
error: Error output from application. This is usually a user error.
error:
error: module.js:340
error: throw err;
error: ^
error: Error: Cannot find module '/opt/run/snapshot/package/plugin/multiplex'
error: at Function.Module._resolveFilename (module.js:338:15)
error: at Function.Module._load (module.js:280:25)
@mkfreeman
mkfreeman / nodejitsu_error
Created November 11, 2014 22:26
Nodejitsu error
info: Welcome to Nodejitsu mikefree
info: jitsu v0.14.0, node v0.10.30
info: It worked if it ends with Nodejitsu ok
info: Executing command deploy
info: Analyzing application dependencies in node plugin/multiplex
info: Checking app availability info343
info: Creating app info343
info: Creating snapshot 0.0.0-2
info: Uploading: [=============================] 100%
npm WARN package.json info343@0.0.0-2 No description