# [R] histogram

Agustin Lobo alobo at paleo.ija.csic.es
Wed Jun 12 12:41:23 CEST 2002

```If your initial values are 1:10,
a <- paste(paste("log(",1:10,sep=""),")",sep="")

would give you a vector string a:
> a
 "log(1)"  "log(2)"  "log(3)"  "log(4)"  "log(5)"  "log(6)"  "log(7)"
 "log(8)"  "log(9)"  "log(10)"

You can use "a" for in the histogram in a number of ways.
Faster:

> b <- rnorm(100)
> b <- b[b>0]
> hist(b)
note tick labels in the x-axis. Here from 0 to 3 by 0.5:
> hist(b,labels=paste(paste("log(",seq(0,3,0.5),sep=""),")",sep=""))

Better:
> hist(b,axes=F)
> axis(1,labels=paste(paste("log(",seq(0,3,0.5),sep=""),")",sep=""))
> axis(2)

Agus

Dr. Agustin Lobo
Instituto de Ciencias de la Tierra (CSIC)
Lluis Sole Sabaris s/n
08028 Barcelona SPAIN
tel 34 93409 5410
fax 34 93411 0012
alobo at ija.csic.es

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.
> Thanks.
>
> Luca
>

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

```