[R] plot of Bernoulli data

Bill Simpson wsi at gcal.ac.uk
Tue Oct 2 13:57:18 CEST 2001


>  x<-sort(runif(100,1,20))
>  p<-pnorm(x,10,3)
>  y<-as.numeric(runif(x)<p)
>  plot(x,y)
>  lines(x,p)
df<-data.frame(x,y)
aggregate(df,list(x=(x<5),(x>5)&(x<10),(x>10) & (x<15),(x>15)), FUN=mean)
gives me what I want but if anyone has a better way to collect the
observations into bins I'd like to hear it. It would be nice to
pass along something like
breaks<-c(5,10,15,20)

Thanks

Bill Simpson

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list