[Rd] Modified Histogram functions

Martin Maechler Martin Maechler <maechler@stat.math.ethz.ch>
Mon, 10 Jul 2000 10:43:10 +0200 (CEST)


>>>>> "Kjetil" == Kjetil Kjernsmo <kjetil.kjernsmo@astro.uio.no> writes:

    Kjetil> Dear all, I have done further modifications on the histogram
    Kjetil> functions that I reported earlier this year, and I hope this
    Kjetil> can be of use and perhaps included in the distribution. I have
    Kjetil> been using this stuff a couple of months myself, and while it
    Kjetil> is nothing sophisticated, it has it's applications. :-) I did a
    Kjetil> few small modifications today to make it a bit more compact.

    Kjetil> I have modified the hist.default() function so that the list it
    Kjetil> returns has class "histogram". I have put the plotting in a
    Kjetil> separate function, plot.histogram(), which is called from
    Kjetil> hist.default if plot=T, and I have made a lines.histogram()
    Kjetil> (calling it "lines", is that a wise choice? It seemed most
    Kjetil> natural, but then again....), which can be used to overlay
    Kjetil> histograms on existing histograms. Here it is obviously a lot
    Kjetil> of room for improvement. E.g. calling plot.histogram() with
    Kjetil> multiple histogram objects could produce a plot where coloumns
    Kjetil> representing the same values are grouped, I haven't addressed
    Kjetil> that. The code is below my .sig.

Your main idea is great and something we (people here) 
have been considering to do as well.

I'd definitely want to put something along these lines into base R.
Please, "everyone chime in!"

    Kjetil> As you can see, there are few changes from your code. The
    Kjetil> biggest change is that hist.default() calls plot.histogram()
    Kjetil> (or rather plot()). Also note that the warning about wrong
    Kjetil> areas only appears in hist.default(). I figured that the user
    Kjetil> is most likely created the histogram object with hist, so s/he
    Kjetil> might no want to be bothered with this warning again. I don't
    Kjetil> know if this is wise, s/he might just have forgotten or
    Kjetil> something. :-)

    Kjetil> I guess plot.histogram() may also be made more compact by
    Kjetil> calling lines.histogram() to plot the actual rects, but I
    Kjetil> didn't find a practical way of doing this, so I didn't... :-)
    Kjetil> And, contrary to the other functions making histogram plots,
    Kjetil> lines.histogram() does take lty as an argument (useful for
    Kjetil> making dotted borders, to separate one histogram from another,
    Kjetil> particulary useful when using colors).

    Kjetil> I've got a function for adding two similar histograms as well,
    Kjetil> but that's so hacked up I guess it isn't worth much.

    Kjetil> BTW, I found a typo in the help for rect: xpd: logical
    Kjetil> (``expand''); if `FLASE', everything is clipped to the plot
    Kjetil> region.

    Kjetil> Hope this is useful for someone... :-)

certainly, thanks a lot!

	   <.... sig and code snipped ....>
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel 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-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._