# [R] Is ther a possibility to display the log(frequency) instead of the frequency in the hist plot?

ben@zoo.ufl.edu ben at zoo.ufl.edu
Thu Jan 18 17:26:29 CET 2001

```On Thu, 18 Jan 2001, Witold Eryk Wolski wrote:

> Uwe Ligges wrote:
>
> > Witold Eryk Wolski wrote:
> > >
> > >  Is there a possibility to display the log(frequency) instead of the
> > > frequency in the hist?
> >
> > I think you want something like the following example:
> >
> >  x <- runif(100) * 10
> >  my.hist <- hist(x)
> >  my.hist   # have a look at the values!
> >  my.hist\$counts <- log(my.hist\$counts, 10)  # logarithm with base 10
> >  plot(my.hist)  # now plot it again with log(frequency)
> >
> > Uwe Ligges
> >
>
> Hi Uwe!
> Some questions still remain to me.
> 1. How take an log if one of the my.hist\$counts equals 0?

You could try log10(my.hist\$counts+1), which is a standard transformation
in ecology.

> 2. You code expample produces an error message which i doesnt understand.
> > plot(my.hist)  # now plot it again with log(frequency)
> Error in plot.window(xlim, ylim, log, asp, ...) :
>         invalid xlim

I don't get it here either.  Are you doing _exactly_ what Uwe suggested
above?  Or are you doing the histogram etc. on your own data (rather than
a sample from runif())?  What is the range of your data?

> 3. I tried as workaround something similar.
> plot(my.hist\$mids,log(my.hist\$counts),type="s") And this would work quite good for
> my needs.
> But problem with log(0) = -Inf still remains.
>
> I think I have to formulate my question more general. Why, and this is an question
> which I am asking myself since
> I am started using  R becouse im using the hist plot quite often,  the hist plot in
> the base package has no similar
> options like eg. the histogram plot in XMGR?

What are those options?

The general answers to the questions "why doesn't R have ... ?" are
usually:

1. it would be a useful feature, but no-one has thought of/suggested it
yet (?);
2. ditto, but no-one has had the time or energy or specific knowledge
required to code it (e.g. full integration of 3D graphics, GAM);
3. it represents something that at least some people (the R Core team,
who tend to be awfully knowledgeable about statistical and graphical
issues) think is a bad idea (e.g. type III sums of squares);
4. it is minor enough, or there is an easy enough way to work around it,
that spending time on it/"bloating" R with it doesn't seem worthwhile.

Ben

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

```