s-news
[Top] [All Lists]

Re: Last question for today

To: Sundar Dorai-Raj <sundar.dorai-raj@pdf.com>
Subject: Re: Last question for today
From: "Overstreet, Jason (FL51)" <Jason.Overstreet@honeywell.com>
Date: Tue, 10 Jan 2006 14:29:25 -0700
Cc: s-news@lists.biostat.wustl.edu
My goodness it is the simple things in life that make things better...

Thanks Sundar.

JLO
-----Original Message-----
From: s-news-owner@lists.biostat.wustl.edu
[mailto:s-news-owner@lists.biostat.wustl.edu] On Behalf Of Sundar Dorai-Raj
Sent: Tuesday, January 10, 2006 4:11 PM
To: Overstreet, Jason (FL51)
Cc: s-news@lists.biostat.wustl.edu
Subject: Re: [S] Last question for today

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 *
> 
--------------------------------------------------------------------
This message was distributed by s-news@lists.biostat.wustl.edu.  To
unsubscribe send e-mail to s-news-request@lists.biostat.wustl.edu with
the BODY of the message:  unsubscribe s-news

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