File: useR2007plot.rhtml

package info (click to toggle)
rapache 1.2.10-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,368 kB
  • sloc: sh: 18,629; ansic: 10,417; perl: 5,675; javascript: 2,800; makefile: 307
file content (26 lines) | stat: -rw-r--r-- 824 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<%
p1 <- ifelse(is.null(GET$p1),.95,as.numeric(GET$p1))
p2 <- ifelse(is.null(GET$p2),.7,as.numeric(GET$p2))
mo <- ifelse(is.null(GET$mo),9,as.numeric(GET$mo))
options(hverbose=FALSE,verbose=FALSE)
library(Hmisc)
PLOTDIR='test/images'
plotname <- paste('plot.',sprintf('%.4f.%.4f.%d',p1,p2,mo),'.png',sep='')
filename <- file.path(PLOTDIR,plotname)
if (!file.exists(filename)){
	png(type='cairo',filename=filename,width=600,height=600)
	sink('/dev/null')
	sc <- Weibull2(c(1,3),c(p1,p2))
	rcens <- function(n) 1 + (5-1) * (runif(n) ^ .5)
	f <- Quantile2(sc,
		hratio=function(x) ifelse(x <= mo/12, 1, .75),
		dropin=function(x) ifelse(x <= .5, 0, .15 * (x-.5)/(5-.5)),
		dropout=function(x) .3*x/5
	)
	par(mfrow=c(2,2))
	plot(f,'all',label.curves=list(keys='lines'))
	dev.off()
	sink()
}
%>
<img src="/images/<%=plotname%>">