Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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