Something like:
merge(x, aggregate(list(Mean = x$V1), x["V4"], mean))
where x is your "Data.Set.1" below.
--sundar
Overstreet, Jason (FL51) wrote:
Thanks to all for helping. I appreciate the kindness. Truly, I do.
Last question of the day...
I want to assign the mean to each row of input (V4) group variable.
Data.Set.1
V1 V2 V3 V4
30 a 1 u1
32 NA 1 u1
31 NA 1 u1
28 a 1 u1
2 b 2 u2
3 b NA u2
1 b 2 u2
4 b 2 u2
2 b 2 u2
10 c 3 u3
12 c 3 u3
11 c NA u3
13 c 3 u3
12 c 3 u3
45 d 4 u4
44 d 4 u4
52 e NA u4
Desired result:
V1 V2 V3 V4 Mean
30 a 1 u1 30.25
32 NA 1 u1 30.25
31 NA 1 u1 30.25
28 a 1 u1 30.25
2 b 2 u2 2.4
3 b NA u2 2.4
1 b 2 u2 2.4
4 b 2 u2 2.4
2 b 2 u2 2.4
10 c 3 u3 11.6
12 c 3 u3 11.6
11 c NA u3 11.6
13 c 3 u3 11.6
12 c 3 u3 11.6
45 d 4 u4 44.5
44 d 4 u4 44.5
52 e NA u4 52
***Jason Overstreet*
*Statistician*
*Honeywell DSES*
*(727) 539-3964 *
|