[R] log-scale density plots (was histogram)

Prof Brian D Ripley ripley at stats.ox.ac.uk
Wed Jun 12 11:19:33 CEST 2002

On Wed, 12 Jun 2002, Luca De Benedictis wrote:

> Dear friends,
> I have been following the help-list in the next two months and I would
> like to tell how much I admire the effort of such a great teem of R
> expert. I am learning a lot. Thank you.
> My problem is the following. I work with a fairly large data set (700
> productive sectors, 70 countries, 25 years) and I am applying kernel
> density (using MASS or sm) to sectoral exports which have markedly
> skewed distributions, so I do the analysis on a log scale.
> What I would like when I plot histograms or densities is to have on the
> horizontal axis not the value y which is equal to log(x) but the
> expression log(x) itself (i.e. log(0.3), log(1), log(34),...)
> I have played a little bit with names.arg :
> plot(density(log(x[,3]),width=0.4, names.arg="log(x)")
> but I was not very successful. Any suggestion would be appreciated.

How about

x <- rlnorm(700)
den <- density(log(x))
den$x <- exp(den$x)
plot(den, log="x", title="something meaningful")


Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

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