[R] distribution graph

(Ted Harding) ted.harding at nessie.mcc.ac.uk
Fri Mar 23 20:20:43 CET 2007


On 23-Mar-07 16:55:40, Marc Schwartz wrote:
> [...]
> How about something like this:
> 
> 
> DistPlot <- function(x, digits = 1, ...)
> {
>   x <- round(x, digits)
>   
>   Tab <- table(x)
> 
>   Vals <- sapply(Tab, function(x) seq(x) - mean(seq(x)))
> 
>   X.Vals <- unlist(Vals, use.names = FALSE)
>   tmp <- sapply(Vals, length)
>   Y.Vals <- rep(names(tmp), tmp)
> 
>   plot(X.Vals, Y.Vals, ...)
> }
> 
> 
> Vec <- exp(rnorm(200, sd = 0.25) + 2) / 5
> 
> DistPlot(Vec, pch = 19)

Very pretty, Marc -- and magic code!!

Ted.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 23-Mar-07                                       Time: 19:20:04
------------------------------ XFMail ------------------------------



More information about the R-help mailing list