s-news
[Top] [All Lists]

Re: Last question for today

To: "Overstreet, Jason (FL51)" <Jason.Overstreet@honeywell.com>
Subject: Re: Last question for today
From: Sundar Dorai-Raj <sundar.dorai-raj@pdf.com>
Date: Tue, 10 Jan 2006 13:11:04 -0800
Cc: s-news@lists.biostat.wustl.edu
In-reply-to: <67BDC44EE870F04183CA36084D53EA9B14ABAAA8@fl51m01a.space.honeywell.com>
Organization: PDF Solutions, Inc.
References: <67BDC44EE870F04183CA36084D53EA9B14ABAAA8@fl51m01a.space.honeywell.com>
User-agent: Mozilla Thunderbird 1.0.2 (Windows/20050317)
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 *


<Prev in Thread] Current Thread [Next in Thread>