Skip to content

Instantly share code, notes, and snippets.

View abresler's full-sized avatar

Alex Bresler abresler

View GitHub Profile
@abresler
abresler / neuralnetR.R
Created September 24, 2015 16:35 — forked from mick001/neuralnetR.R
A neural network exaple in R. Full article at:
# Set a seed
set.seed(500)
library(MASS)
data <- Boston
# Check that no data is missing
apply(data,2,function(x) sum(is.na(x)))
# Train-test random splitting for linear model
@abresler
abresler / README.md
Created March 2, 2016 19:15 — forked from timelyportfolio/README.md
nesting and summarizing in R and d3.js

Built with blockbuilder.org

Nesting and summarizing data is a very common task for data analysis. I thought it would be nice to view parallel ways of nesting and summarizing with both

  • R | tidyr and dplyr
  • JavaScript | d3.js ...v4 for fun

To avoid context switching, I'll take advantage of the R package V8. If you are an R user, then these d3.js gists might be helpful d3 nest examples and Mister Nester.

Tables Are Like Cockroaches
========================================================
As much as I would like to completely replace all tables with beautiful, intuitive, and interactive charts, tables like cockroaches cannot be eliminated. Based on this very [interesting discussion on the Perceptual Edge forum](http://sfew.websitetoolbox.com/post/Old-or-oldest-data-table-5702966) with source [Exploring the Origins of Tables for Information Visualization](http://api.viglink.com/api/click?format=go&key=ccc2217bc2b75c4bdf5f7e57267f0464&loc=http%3A%2F%2Fsfew.websitetoolbox.com%2Fpost%2FOld-or-oldest-data-table-5702966&v=1&libid=1365001395530&out=http%3A%2F%2Fcsis.pace.edu%2F~marchese%2FPapers%2FIV11%2FMarchese_IV%252711.pdf&ref=http%3A%2F%2Fwww.google.com%2Furl%3Fsa%3Dt%26rct%3Dj%26q%3D%26esrc%3Ds%26frm%3D1%26source%3Dweb%26cd%3D2%26ved%3D0CDoQFjAB%26url%3Dhttp%253A%252F%252Fsfew.websitetoolbox.com%252Fpost%252FOld-or-oldest-data-table-5702966%26ei%3DpERcUcvxPImY9QTKi4GwCg%26usg%3DAFQjCNFppNIFLhtMVC3W9Xklbffh8lAm
@abresler
abresler / pagerank.R
Last active December 18, 2015 15:37 — forked from andrie/pagerank.R
## Analyze R packages for popularity, using pagerank algorithm
# Inspired by Antonio Piccolboni, http://piccolboni.info/2012/05/essential-r-packages.html
library(miniCRAN)
library(igraph)
library(magrittr)
# Download matrix of available packages at specific date ------------------
@abresler
abresler / dogs.R
Last active December 18, 2015 15:37
# Reading in 'dogs.csv'
# Created by Alex Bresler, available at:
# https://github.com/abresler/abresler.github.io/blob/master/blog/2015/february/exploring_agility_show/data/dogs.csv
dogs <- read.csv("dogs.csv", header = TRUE, stringsAsFactors = FALSE)
# Setting a numeric id
node_id <- 1:nrow(dogs)
# Getting unique values for the 'breed' column
unique_node_2 <- unique(dogs$breed)
# Get the latest version of 'DiagrammeR'
install_github("rich-iannone/DiagrammeR")
# Create a 'nodes' data frame
nodes <- sample(1:100, 100, replace = FALSE)
style <- rep("filled", 100)
fillcolor <- c(rep("turquoise", 20), rep("pink", 20),
rep("ochre", 20), rep("gray40", 20),
#devtools::install_github("rstudio/leaflet", ref="feature/color-legend")
library(leaflet)
library(RColorBrewer)
set.seed(100)
pdf <- data.frame(Latitude = runif(100, -90,90), Longitude = runif(100, -180,180))
#make a property with colors
pdf$Study <- rep(1:10,10)
#need to create a pal using colorbin
### Title: Back to basics: High quality plots using base R graphics
### An interactive tutorial for the Davis R Users Group meeting on April 24, 2015
###
### Date created: 20150418
### Last updated: 20150423
###
### Author: Michael Koontz
### Email: mikoontz@gmail.com
### Twitter: @michaeljkoontz
###
@abresler
abresler / world-cities-diagrammer.R
Created October 5, 2015 17:45 — forked from rich-iannone/world-cities-diagrammer.R
Demonstration code for plotting a graph of world cities along with country borders with the DiagrammeR R package.
# Installation
#install.packages("devtools")
devtools::install_github("rich-iannone/DiagrammeR")
library(DiagrammeR)
# Create a graph of border coordinates
country_graph <- country_graph()
# Read in a CSV with location and population data for cities all over the world
@abresler
abresler / diagrammer-bball-vis.R
Last active December 18, 2015 15:11
Simple visualization of NBA player movements using the DiagrammeR R package
library(DiagrammeR)
library(magrittr)
library(visNetwork)
moments <-
'https://gist.githubusercontent.com/rich-iannone/9c4e50cd5d811b841349/raw/65bc97ddac2f9e52a4252fcf2060007fe1afeb7d/moment.csv' %>%
read_csv()
# Generate the court
court <-