Skip to content

Instantly share code, notes, and snippets.

@lmcstro
lmcstro / location_analysis_s2.r
Created March 8, 2018 19:39
Blog on Location Analysis: Script for multilocation report
# Section 1. Multiple Journey Days
# this section generates a report of the to,from and days that have more
# journeys than days travelled (i.e. there was on average more than 1 trip per day)
# select the days/to/from that have more journeys than journey days
out.m <- which(journey.count.x>pred.journey.x, arr.in=TRUE)
# select the journey count for the multi-trip dates
journey.count <- journey.count.x[journey.count.x>pred.journey.x]
@lmcstro
lmcstro / location_analysis_s1.r
Created March 8, 2018 19:37
Blog on Location Analysis: Creating the location and frequency matrices
# Section 1. Load the data from journey file
# this section takes in the dataframes (reads them in first from CSV files)
l.journeys <- list.files(pattern = "*_journey.csv")
# select a particlar car and day to examine
x.journey.number <- 4
df.x <- read.csv(l.journeys[x.journey.number]
@lmcstro
lmcstro / test.r
Created February 28, 2018 14:55
an experiment in GIST for R
# select a particlar car and day to examine
x.journey.number <- 4
x.day <- "Monday"
# Big look to process all the records
#for (x.journey.number in 1:length(l.journeys)) {
#} # end big loop
df.x <- read.csv(paste(x.results.dir,"pattern_",l.journeys[x.journey.number]