# 2012.01.14 setwd("/Users/jameshanley/Documents/work/Espionage") source("ExtractLinesFromLargeFileFunction.R") result = ExtractLinesFromLargeFileFunction("CRPRiskStratificationP4.ps",90000,10000) LENGTH=unlist(result[3]) ; LENGTH ; summary(LENGTH) X = result[1][[1]] ; Y = result[2][[1]] ; length(X) # flip vertical if need be... (not here) x.min=min(unlist(X)); x.max=max(unlist(X)) y.min=min(unlist(Y)); y.max=max(unlist(Y)) # NP=length(X) ; for (i in 1:NP) Y[[i]] = y.max-Y[[i]] y.min=min(unlist(Y)); y.max=max(unlist(Y)) c(x.min,x.max,y.min,y.max) # plot selected sections of page par(mfrow=c(1,1),mar = c(.01,.01,.1,.1)) x.range=c(0.50,0.95)*x.max ; y.range=c(0.40,0.60)*y.max plot(x.range,y.range,col="white") range=1:length(X) for (i in range) { xa=0; if (X[[i]][1] > X[[i]][length(X[[i]])]) xa=1 ya=0; if (Y[[i]][1] > Y[[i]][length(Y[[i]])]) ya=1 text(X[[i]][1],Y[[i]][1], toString(i), cex=0.5,adj=c(xa,ya) ) LL=LENGTH[i] lines(X[[i]],Y[[i]]) ; text(X[[i]][LL],Y[[i]][LL], toString(i), cex=0.5,adj=c(xa,ya) ) } LENGTH T=0:7 i.x.max=15; i.x.zero=8 ; index=5 dx=(X[[i.x.max]][1]-X[[i.x.zero]][1])/7 ; dx; t=(X[[index]] - X[[i.x.zero]][1])/dx ; t i.y.100=21; i.y.75 = 16 ; dy = (Y[[21]][1]-Y[[20]][1]) / 0.05 ; dy S = 1- (Y[[21]][1] - Y[[index]])/dy ; S S.s = S[seq(3,length(S),2)] ; S.s T.t = t[seq(2,length(t)-1,2)] ; T.t cbind(T.t,S.s) pts=length(S.s) ratio=S.s[1:pts ] / c(1,S.s[1:(pts-1)]) ; jumps = c(1,S.s[1:(pts-1)]) - S.s[1:pts ] ; jumps plot(T.t,jumps,ylim=c(0,.1)) # jumps not perfectly monotonic, even in original graph Y[[index]][seq(2,48,2)] # look at 3 and 4 Y[[index]][seq(2,46,2)] - Y[[index]][seq(4,48,2)] # must be some post processing, or rounding ... n.risk=round( 1/(1-ratio), 0) ; n.risk N.risk=c(237,233,223,215,204,182,31,0) T = 0:7 par(mfrow=c(1,1),mar = c(4,5,1,1)) plot(T.t,n.risk,ylim=c(0,300),pch=19,cex=0.8, xlab="Years",ylab="N at Risk") points(T,N.risk,col="green",cex=1.25,pch=19) text(T.t[12], n.risk[12], "(2 events)", adj=c(1.15,0.5),cex=1)