This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyr) | |
library(dplyr) | |
library(Lahman) | |
### Some extended examples re dplyr using the Lahman baseball database | |
### Problem 1: | |
### Get the season batting statistics for the 2013 Los Angeles Dodgers, | |
### including slugging percentage, on-base percentage and their sum OPS. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Some useful keyboard shortcuts for package authoring: | |
# | |
# Build and Reload Package: 'Ctrl + Shift + B' | |
# Check Package: 'Ctrl + Shift + E' | |
# Test Package: 'Ctrl + Shift + T' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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") |
OlderNewer