Re: [R] Calculated mean value based on another column bin from dataframe.

2011-04-06 Thread Fabrice Tourre
Thanks. Before I never used findInterval function. It seems very nice. On Wed, Apr 6, 2011 at 11:20 PM, David Winsemius wrote: > > On Apr 6, 2011, at 9:46 AM, Fabrice Tourre wrote: > >> Dear Henrique Dallazuanna, >> >> Thank you very much for your suggestion. >> >> It is obvious that your method

Re: [R] Calculated mean value based on another column bin from dataframe.

2011-04-06 Thread David Winsemius
On Apr 6, 2011, at 9:46 AM, Fabrice Tourre wrote: Dear Henrique Dallazuanna, Thank you very much for your suggestion. It is obvious that your method is better than me. Is it possible to use cut, table,by etc? Whether there is some aggregate function in R can do this? Thanks. On Wed, Apr 6,

Re: [R] Calculated mean value based on another column bin from dataframe.

2011-04-06 Thread Fabrice Tourre
Dear Henrique Dallazuanna, Thank you very much for your suggestion. It is obvious that your method is better than me. Is it possible to use cut, table,by etc? Whether there is some aggregate function in R can do this? Thanks. On Wed, Apr 6, 2011 at 2:16 PM, Henrique Dallazuanna wrote: > Try t

Re: [R] Calculated mean value based on another column bin from dataframe.

2011-04-06 Thread Henrique Dallazuanna
Try this: fil <- sapply(ran, '<', e1 = dat[,1]) & sapply(ran[2:(length(ran) + 1)], '>=', e1 = dat[,1]) mm <- apply(fil, 2, function(idx)mean(dat[idx, 2])) On Wed, Apr 6, 2011 at 5:48 AM, Fabrice Tourre wrote: > Dear list, > > I have a dataframe with two column as fellow. > >> head(dat) >       V

[R] Calculated mean value based on another column bin from dataframe.

2011-04-06 Thread Fabrice Tourre
Dear list, I have a dataframe with two column as fellow. > head(dat) V1 V2 0.15624 0.94567 0.26039 0.66442 0.16629 0.97822 0.23474 0.72079 0.11037 0.83760 0.14969 0.91312 I want to get the column V2 mean value based on the bin of column of V1. I write the code as fellow. It wor