Skip to content

Instantly share code, notes, and snippets.

View Emaasit's full-sized avatar
🎯
Focusing

Daniel Emaasit Emaasit

🎯
Focusing
View GitHub Profile
@Emaasit
Emaasit / hide_code_pdf.md
Created April 3, 2018 19:24 — forked from macoj/hide_code_pdf.md
Hiding code when exporting jupyter notebook to pdf
@Emaasit
Emaasit / STB.R
Created November 22, 2016 21:17 — forked from xiangze/STB.R
Stick breaking process in stan
#from BUGS book page 293
#Stick-breaking process
#http://www2.imm.dtu.dk/courses/02443/projects/Roeder_JASA_1990.pdf
library(rstan)
C <- 10
data <-read.csv("data.csv")
N <-nrow(data)
model <-stan_model("STB.stan")
@Emaasit
Emaasit / build-package.Rmd
Created February 12, 2016 03:49
Some useful keyboard shortcuts for package authoring
# Some useful keyboard shortcuts for package authoring:
#
# Build and Reload Package: 'Ctrl + Shift + B'
# Check Package: 'Ctrl + Shift + E'
# Test Package: 'Ctrl + Shift + T'
@Emaasit
Emaasit / data-upload.Rmd
Created February 11, 2016 00:19
Uploading Big Data to AWS
I had to do this today and thought of our discussion. I figured I'd document the commands and send them over - maybe it'll help.
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-using-volumes.html
Commands:
$ sudo su
# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
@Emaasit
Emaasit / magellan.Rmd
Last active November 23, 2015 20:33
Questions about Geo-spatial Analytics on Spark Using Magellan
After watching the webinar conduted by Hortonworks on Geospatial Analytics, I had a few questions. As a Transportation Data Analyst,
I work on alot of spatially referenced transportation data such as crashes, vehicle and people travel patterns, asset location management
to mention but a few. Does the magellan package provide functionality for the following:
1. Geolocating of events (like crashes) on a map. Like I have a dataset of crashes with location information. Can I plot that onto a map?
2. Support for different linear referencing systems. Like in roadways events can be identified using the Mile Post and the Roadway name/ID. An example is, we can say this crash occured on Interstate 15 at mile post 20. Using ESRI GIS, you can geolcate such a crash on a map.
3. Hot Spot Analytics. We are interested in finding which areas experience significantly high crashes than others.
4. Spatial Autocorrelation. Is there functionality for spatial autocorrelation using algorithms like Local Moran's I Index, Geti
# Set the system environment variables
Sys.setenv(SPARK_HOME = "C:/Apache/spark-1.4.1")
.libPaths(c(file.path(Sys.getenv("SPARK_HOME"), "R", "lib"), .libPaths()))
#load the Sparkr library
library(SparkR)
# Create a spark context and a SQL context
sc <- sparkR.init(master = "local")
sqlContext <- sparkRSQL.init(sc)
## Download h2o from CRAN
## When downloading from CRAN, keep in mind that the initial
## download from CRAN contains only the R package
install.packages("h2o")
library(h2o)
localH2O <- h2o.init()
## To import small iris data file from H2O's package
irisPath = system.file("extdata", "iris.csv", package="h2o")
iris.hex = h2o.importFile(localH2O, path = irisPath, key = "iris.hex")
@Emaasit
Emaasit / regModel.R
Created February 16, 2015 12:34
This script is used to model pedestrian and bike crashes
# this R script is used to model the relationship between crash frequency and
# contributing factors
# I used a negative binomial model to model the relationships
# read the data into R
ped_data<-readRDS("data/countModel/ped_data.rds")
bike_data<-readRDS("data/countModel/bike_data.rds")
@Emaasit
Emaasit / densityPlot.R
Created February 16, 2015 12:33
This script is used to produce heatmaps
# this R script is used to develop crash density plots using kernel density method
# the purpose is to identify locations with high crashes
# install the required packages
install.packages("rjson")
install.packages("devtools")
library(devtools)
install_github("rstudio/leaflet")
install_github("ramnathv/rCharts")
@Emaasit
Emaasit / script.R
Created February 8, 2015 11:17
ggplot2. Elegant graphics for data manipulation
## Examples for LVRUG meetup, Nov. 4, 2014
## All examples use either generated or built-in R/ggplot2 data frames
################## Single-layer plots ######################
set.seed(5409) # for reproducibility
DF <- data.frame(gp = sample(LETTERS[1:3], 1000, replace = TRUE),
x = rnorm(1000))