Created
May 8, 2015 14:14
-
-
Save AndrewTheTM/793bdd071e1cb8f78b74 to your computer and use it in GitHub Desktop.
Example of Trip Length Frequencies in R
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
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