Skip to content

Instantly share code, notes, and snippets.

@AndrewTheTM
Created May 8, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AndrewTheTM/793bdd071e1cb8f78b74 to your computer and use it in GitHub Desktop.
Save AndrewTheTM/793bdd071e1cb8f78b74 to your computer and use it in GitHub Desktop.
Example of Trip Length Frequencies in R
source("00Keys.R")
source("http://raw.githubusercontent.com/osPlanning/omx/dev/api/r/omx.R")
library(ggplot2)
library(plyr)
hskimpk=readMatrixOMX(paste(modelFolder,"HSKIM_PK1.OMX",sep=""),"TIME")
askimam=readMatrixOMX(paste(modelFolder,"AMAsn.OMX",sep=""),"TIME")
H5close()
getTLF=function(skim,trips){
tt=data.frame(X2=numeric(),n=numeric())
for(c in 1:ncol(trips)){
t=data.frame(cbind(trips[,c],skim[,c]))
t$X2=floor(t$X2+0.5)
tt=rbind(tt,ddply(t,.(X2),summarize,n=sum(X1)))
}
tlf=ddply(tt,.(X2),summarize,n=sum(n))
tlf$Pct=tlf$n/sum(tlf$n)
return(tlf)
}
hbwPkDistTLF=getTLF(hskimpk,hbwpk)
pHBWPKTLF=ggplot(hbwPkDistTLF,aes(x=X2,y=Pct,color='Peak Distribution'),color='red')+geom_line()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment