[R] x-y plot as an histogram
jim at bitwrit.com.au
Thu Oct 29 23:29:45 CET 2009
On 10/30/2009 06:12 AM, Federico Abascal wrote:
> I am investigating a problem for which I found no solution.
> I have a matrix with two columns. I have plotted it as an x-y plot
> But this is not apropriate for my purposes. I need to group the data
> in matrix[,1] into groups (as an histogram would do). Then I have to
> calculate the average of matrix[,2] for each group.
> Before starting with loops and loops I would like to know if is there
> some way to do this easily with R.
If I understand your problem, I think you want first to use "cut":
where ??? is the vector of breakpoints that you want. Then you can use
whatever averaging function (AVEFUN) you want with something like "by":
More information about the R-help