[R] table of means/medians across bins used for a histogram

Gabor Grothendieck ggrothendieck at gmail.com
Mon May 1 05:15:29 CEST 2006


My understanding is that you want to replace each rate with its average
over the associated bin and then plot age against that.  In that
case try this:

> DF  # test data
    age rate bin
1 0.002 10.0   A
2 0.045  0.1   B
3 0.130 15.0   A
4 0.150 34.0   D
> with(DF, plot(ave(rate, bin), age))

Assuming they
are stored in vectors
the columns are age, rate, bin we would have

plot(ave(clock, bin), age)

On 4/30/06, lalitha viswanath <lalithaviswanath at yahoo.com> wrote:
> Hi
> I am trying to get a table of means of parameter 1
> across BINS of parameter 2.
>
> I am working in proteomics and a sample of my data is
> as follows
>
> cluster-age clock-rate(evolutionary rate) scopclass
> 0.002       10                              A
> 0.045       0.1                             B
> 0.13        15                              A
> 0.15        34                              D
> ....
> ....
> ....
> ....
>
> Scop class has only 9 distinct categories (A-I)
> Whereas cluster-age and clock-rate are discrete
> variables greater than 0.
>
> I am trying to do two things with this kind of data,
> out of which I managed to accomplish one thanks to the
> documentation and pre-existing queries on the mailing
> lists.
> 1. Plot a histogram of the age distribution with scop
> class category superimposed on each bin. I managed to
> do this with barplot2.
> 2. Now I am trying to plot a scatter plot of the age
> v/s the clock-rate. However to eliminate possible
> sampling errors, we are trying to get an average of
> the clock-rate for each of the bins used above.
> i.e. before plotting a x-y plot, i wish to compute
> average clock-rate in each of the bins for the age and
> then plot a x-y plot of the age v/s clock rate.
>
> Can anyone point me to appropriate functions for the
> same?
> I am trying to work with prop.table, cut, break, etc.
> But I am not heading anywhere.
>
> Thanks
> Lalitha
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>




More information about the R-help mailing list