Re: [R] Including percentage values inside columns of a histogram

2021-08-17 Thread Bert Gunter
Ah yes. Duhhh... Thanks Rui. So h$density *diff(h$breaks) *100 will give the percentages. No need for arithmetic beyond that. Bert On Tue, Aug 17, 2021 at 12:03 PM Rui Barradas wrote: > > Hello, > > > > Às 19:28 de 17/08/21, Bert Gunter escreveu: > > Inline below. > > > > > > > > On Tue, Aug

Re: [R] Including percentage values inside columns of a histogram

2021-08-17 Thread Rui Barradas
Hello, Às 19:28 de 17/08/21, Bert Gunter escreveu: Inline below. On Tue, Aug 17, 2021 at 4:09 AM Rui Barradas wrote: Hello, I had forgotten about plot.histogram, it does make everything simpler. To have percentages on the bars, in the code below I use package scales. Note that it

Re: [R] Including percentage values inside columns of a histogram

2021-08-17 Thread Bert Gunter
Inline below. On Tue, Aug 17, 2021 at 4:09 AM Rui Barradas wrote: > > Hello, > > I had forgotten about plot.histogram, it does make everything simpler. > To have percentages on the bars, in the code below I use package scales. > > Note that it seems to me that you do not want densities, to

Re: [R] Including percentage values inside columns of a histogram

2021-08-17 Thread Rui Barradas
Hello, I had forgotten about plot.histogram, it does make everything simpler. To have percentages on the bars, in the code below I use package scales. Note that it seems to me that you do not want densities, to have percentages, the proportions of counts are given by any of

Re: [R] Including percentage values inside columns of a histogram

2021-08-16 Thread Paul Bernal
Thank you very much Mr. Gunter, I will give it a try. Cheers, Paul El lun., 16 de agosto de 2021 7:49 p. m., Bert Gunter < bgunter.4...@gmail.com> escribió: > I may well misunderstand, but proffered solutions seem more complicated > than necessary. > Note that the return of hist() can be saved

Re: [R] Including percentage values inside columns of a histogram

2021-08-16 Thread Bert Gunter
I may well misunderstand, but proffered solutions seem more complicated than necessary. Note that the return of hist() can be saved as a list of class "histogram" and then plotted with plot.histogram(), which already has a "labels" argument that seems to be what you want. A simple example is"

Re: [R] Including percentage values inside columns of a histogram

2021-08-16 Thread Paul Bernal
Dear Jim, Thank you so much for your kind reply. Yes, this is what I am looking for, however, can´t see clearly how the bars correspond to the bins in the x-axis. Maybe there is a way to align the amounts so that they match the columns, sorry if I sound picky, but just want to learn if there is a

Re: [R] Including percentage values inside columns of a histogram

2021-08-16 Thread Jim Lemon
Hi Paul, I just worked out your first request: datasetregs<-<-structure(list(Date = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,

Re: [R] Including percentage values inside columns of a histogram

2021-08-16 Thread Paul Bernal
This is way better, now, how could I put the frequency labels in the columns as a percentage, instead of presenting them as counts? Thank you so much. Paul El lun, 16 ago 2021 a las 17:33, Rui Barradas () escribió: > Hello, > > You forgot to cc the list. > > Here are two ways, both of them

Re: [R] Including percentage values inside columns of a histogram

2021-08-16 Thread Rui Barradas
Hello, You forgot to cc the list. Here are two ways, both of them apply hist() and text() to Amount split by Date. The return value of hist is saved because it's a list with members the histogram's bars midpoints and the counts. Those are used to know where to put the text labels. A vector

Re: [R] Including percentage values inside columns of a histogram

2021-08-16 Thread Rui Barradas
Hello, The function Hist comes from what package? Are you sure you don't want a bar plot? agg <- aggregate(Amount ~ Date, datasetregs, sum) bp <- barplot(Amount ~ Date, agg) with(agg, text(bp, Amount/2, labels = Amount)) Hope this helps, Rui Barradas Às 22:54 de 16/08/21, Paul Bernal

[R] Including percentage values inside columns of a histogram

2021-08-16 Thread Paul Bernal
Hello everyone, I am currently working with R version 4.1.0 and I am trying to include (inside the columns of the histogram), the percentage distribution and I want to generate three histograms, one for each fiscal year (in the Date column, there are three fiscal year AF 2017, AF 2020 and AF