On 25/03/2009 7:36 PM, Aldi Kraja wrote:
Hi,
I have a data.frame with many variables for which I am performing the
mean by subgroup, for a pair of variables at a time, where one of them
for each pair defines the subgroup. The subgroups in the x$cm1 are 0, 1
and 2.
x
ph1 cm1
0.2345 2
1. 1
Dear Aldi,
Yes . Here it is:
as.vector(with(x, by(ph1, cm1, mean,na.rm=TRUE)))
or
with(x,tapply(phi1,cm1,mean,na.rm=TRUE))
See ?mean and ?tapply for more details.
HTH,
Jorge
On Wed, Mar 25, 2009 at 7:36 PM, Aldi Kraja wrote:
> Hi,
>
> I have a data.frame with many variables for which I
Hi,
I have a data.frame with many variables for which I am performing the
mean by subgroup, for a pair of variables at a time, where one of them
for each pair defines the subgroup. The subgroups in the x$cm1 are 0, 1
and 2.
x
ph1 cm1
0.2345 2
1. 1
2.0033 0
0. 2
1.0033 1
0.2345 0
1.222
3 matches
Mail list logo