I do not believe your code (minimal as it is) would work: the correct
argument is "breaks". More generally, do you really mean to say that hist(x,
breaks = 20) immediately returns the bin counts? It doesn't on my machine
and if you knew how to get the counts, you should be able to get the
midpoints as well.

Try this

x = rnorm(5000)
HistOut = hist(x, breaks = 20)
HistOut$mids # will give midpoints for each bin of this histogram

If you need proper means, rather than midpoints:

# I *think* this works -- no guarantees: it assigns x to bins based on the
histogram breaks, averages those by bin, and then we pull out just the
unique values and sort them
V = sort(unique(ave(x,cut(x,HistOut$breaks))))

It does seem to be a somewhat strange task to use histogram breaks to get
means though: if I were you, I'd spend a minute or two contemplating if this
really makes the most sense, rather than just doing the breaks in some way
yourself directly.

There may well be a more elegant way but I think this gets the job done.

Hope it helps,

Michael

On Tue, Aug 23, 2011 at 9:46 AM, Francesco Nutini <
nutini.francesco@gmail.com> wrote:

>
> Dear R-users,
>
> I need to produce a histogram where for every breaks there are the mean of
> the data.
> I tried tu use the function >hist(x, break=20 ... ) but this return the
> numerosity for every breaks, not the mean.
> Any hint?
>
> Thanks in advance,
>
> francesco
>
> ---------------------------------------
> Francesco Nutini
> CNR-IREA
>     Ist. per il Rilevamento Elettromagnetico dell'Ambiente
>     Via Bassini 15, 20133 Milano (Italy)
>     Tel: +39-02 23699 297
>     http://www.irea.cnr.it
>     nutini.f@irea.cnr.it
> Skype: uitko@hotmail.it
> Univ. mail: francesco.nutini@unimi.it
> ---------------------------------------
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

	[[alternative HTML version deleted]]

