[R] distribution graph
(Ted Harding)
ted.harding at nessie.mcc.ac.uk
Fri Mar 23 15:22:53 CET 2007
[Apologies -- there were errors in the code I posted previously.
A corrected version is below]
On 23-Mar-07 11:06:49, Plessen, Christian von wrote:
>
> I am looking for a way to produce a "distribution graph" as in the
> example:
>
> (http://cecsweb.dartmouth.edu/release1.1/datatools/dgraph.php?year=2003&
> geotype=STD_HRR&event=A01_DIS&eventtype=UTIL
>
> Anybody who can help?
>
> Christian von Plessen
> Department of Pulmonary Medicine
> Haukeland university hospital
> Bergen
> Norway
The following (which anyway needs refinement, and can very
probably be done better) provides a basis (illustrated using
a sample from a log-normal distribution):
X<-exp(rnorm(200,sd=0.25)+2)/5
H<-hist(X,breaks=20)
C<-H$counts
Y<-H$mids
C1<-C/2
C0<-(-(C1[1]-1/2)):(C1[1]-1/2); n0<-length(C0)
plot(C0,rep(Y[1],n0),xlim=c(-max(C)/2,max(C)/2),ylim=c(min(Y),max(Y)))
for(i in (2:length(Y))){
if(C[i]==0) next
C0 <- (-(C1[i] - 1/2)):(C1[i] - 1/2); n0<-length(C0)
points(C0,rep(Y[i],n0))
}
Hoping this helps!
Ted.
--------------------------------------------------------------------
E-Mail: (Ted Harding) <ted.harding at nessie.mcc.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 23-Mar-07 Time: 13:04:51
------------------------------ XFMail ------------------------------
--------------------------------------------------------------------
E-Mail: (Ted Harding) <ted.harding at nessie.mcc.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 23-Mar-07 Time: 14:22:50
------------------------------ XFMail ------------------------------
More information about the R-help
mailing list