Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Daniel Emaasit Emaasit

🎯
Focusing
View GitHub Profile
@Emaasit
Emaasit / hide_code_pdf.md
Created Apr 3, 2018 — forked from macoj/hide_code_pdf.md
Hiding code when exporting jupyter notebook to pdf
View hide_code_pdf.md
@Emaasit
Emaasit / STB.R
Created Nov 22, 2016 — forked from xiangze/STB.R
Stick breaking process in stan
View STB.R
#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 Feb 12, 2016
Some useful keyboard shortcuts for package authoring
View build-package.Rmd
# 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 Feb 11, 2016
Uploading Big Data to AWS
View data-upload.Rmd
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 Nov 23, 2015
Questions about Geo-spatial Analytics on Spark Using Magellan
View magellan.Rmd
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
View intro-sparkr.R
# 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)
View H2O_script.R
## 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 Feb 16, 2015
This script is used to model pedestrian and bike crashes
View regModel.R
# 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 Feb 16, 2015
This script is used to produce heatmaps
View densityPlot.R
# 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 Feb 8, 2015
ggplot2. Elegant graphics for data manipulation
View script.R
## 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))