s-news
[Top] [All Lists]

Re: group by

To: Rich@mango-solutions.com
Subject: Re: group by
From: "Neung-Hwan Oh" <ultisol@gmail.com>
Date: Wed, 14 Mar 2007 18:58:48 -0400
Cc: "Wensui Liu" <liuwensui@gmail.com>, s-news@wubios.wustl.edu
Dkim-signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=W6iRov5VR0uNDOcK9Ab/I3MDc/AbZD6ydN4haOtsO/d2YJBbLGoCRw70Cuk/pDdCnwiAOCjZ2FgXXyhDudx1qkP0N7Dus0354CE14BY1jCDWoTdoHy13ZRZZhwiPZW9GQFwLiLuXuSAn56hDOcga6ql7mAur8Y6gCFlNRMQb6H4=
Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=Ybu2TMnzAIQKPjxbOHnaHOvVIGJSlmgo4XzCLfd8gXtWpYd0Lnmy3mcsvU5SvncT6mn8cLF0Ec79umg2dVugmxkuyXj3hvIQqwAgAcB2ends9zZ/g4oLSB+zHNGKygWUg50upL1I3EKP/4n3wi3NAA75SJJ8kbB6fHX5YiAWNIM=
In-reply-to: <20070314211746.3443D136DCF@mailgate.biostat.wustl.edu>
References: <20070314211413.E237E137456@mailgate.biostat.wustl.edu> <20070314211746.3443D136DCF@mailgate.biostat.wustl.edu>
Thanks a lot for the quick replies.
But, doesn't "tapply" or "aggregate" provide a matrix format rather
than data frame format?

On 3/14/07, Rich@mango-solutions.com <Rich@mango-solutions.com> wrote:
Sorry ...

I mean "aggregate(df$value, df[,1:3], mean)"

Rich.
mangosolutions

-----Original Message-----
From: Rich@Mango-Solutions.com [mailto:Rich@Mango-Solutions.com]
Sent: 14 March 2007 21:14
To: 'Wensui Liu'; 'Neung-Hwan Oh'
Cc: s-news@wubios.wustl.edu
Subject: Re: [S] group by

Yes ... you can use tapply in S.  For the structure you're using, I'd
probably recommend "aggregate" though ...

Something like "aggregate(df[,1:3], df$value, mean)"

Rich.
mangosolutions

-----Original Message-----
From: Wensui Liu [mailto:liuwensui@gmail.com]
Sent: 14 March 2007 21:02
To: Neung-Hwan Oh
Cc: s-news@wubios.wustl.edu
Subject: Re: [S] group by

I am not sure if in Splus, there is a nice function like tapply() in R or
not.

On 3/14/07, Neung-Hwan Oh <ultisol@gmail.com> wrote:
> Hello,
>
> How can you calculate the following example in s-plus?   In Access, it is
> relatively easy with "Group By" and I am wondering whether there is a
> similar function that I missed in S-Plus.
>
>
>
> "From this table"
>
> site.no date time value
>
> 1 1989/04/27 12:00   1.0
>
> 2 1975/10/01 19:00   2.0
>
> 2 1975/10/01 20:00   4.0
>
> 3 1993/04/10 09:00   3.0
>
> 3 1993/04/10 12:00   6.0
>
> 3 1993/04/10 15:00   9.0
>
>
>
> "To this (averages per date per site)" + (count column?)
>
> 1 1989/04/27 12:00 1.0  (1.0)
>
> 2 1975/10/01 19:30 3.0  (2.0)
>
> 3 1993/04/10 12:00 6.0  (3.0)
>
>
>
> Many thanks!
>
> NH


--
WenSui Liu
A lousy statistician who happens to know a little programming
(http://spaces.msn.com/statcompute/blog)
--------------------------------------------------------------------
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

--------------------------------------------------------------------
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

--------------------------------------------------------------------
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>