Hi folks: I am a SQL guy who just downloaded and installed R yesterday. I am trying to evaluate some "complex" aggregations we are currently performing with Syncsort (and have tried in Oracle) with R. I have loaded data in a dataframe and have performed some of the simple aggregations on a subset of data. What I do not see how to do though, is to "group" the aggregations on a particular key value (e.g., sum market_value over account_id). If you can point me in the right direction I'd very much appreciate it. Thanks! John [[alternative HTML version deleted]]
?by ?aggregate ?ave Further specifics might be forthcoming if self-contained example data and desired output were offered. The help pages will have worked examples, of course. -- David Winsemius On Jan 28, 2009, at 9:13 AM, Rixon, John C. wrote:> Hi folks: > > I am a SQL guy who just downloaded and installed R yesterday. I am > trying to evaluate some "complex" aggregations we are currently > performing with Syncsort (and have tried in Oracle) with R. I have > loaded data in a dataframe and have performed some of the simple > aggregations on a subset of data. What I do not see how to do though, > is to "group" the aggregations on a particular key value (e.g., sum > market_value over account_id). > > If you can point me in the right direction I'd very much appreciate > it. > > Thanks! > > John > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.
Some useful commands are:
by(), aggregate(), ave(), split().
eg
by(market_value, account_id, sum)
-thomas
On Wed, 28 Jan 2009, Rixon, John C. wrote:
> Hi folks:
>
> I am a SQL guy who just downloaded and installed R yesterday. I am
> trying to evaluate some "complex" aggregations we are currently
> performing with Syncsort (and have tried in Oracle) with R. I have
> loaded data in a dataframe and have performed some of the simple
> aggregations on a subset of data. What I do not see how to do though,
> is to "group" the aggregations on a particular key value (e.g.,
sum
> market_value over account_id).
>
> If you can point me in the right direction I'd very much appreciate it.
>
> Thanks!
>
> John
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
Thomas Lumley Assoc. Professor, Biostatistics
tlumley at u.washington.edu University of Washington, Seattle
On Wed, Jan 28, 2009 at 8:13 AM, Rixon, John C. <JCRixon at wellington.com> wrote:> Hi folks: > > I am a SQL guy who just downloaded and installed R yesterday. I am > trying to evaluate some "complex" aggregations we are currently > performing with Syncsort (and have tried in Oracle) with R. I have > loaded data in a dataframe and have performed some of the simple > aggregations on a subset of data. What I do not see how to do though, > is to "group" the aggregations on a particular key value (e.g., sum > market_value over account_id). > > If you can point me in the right direction I'd very much appreciate it.Have a look at the plyr package, http://had.co.nz/plyr, and associated documentation. If you're doing pivot table type aggregations, you might also want to have a look at the reshape package, http://had.co.nz/reshape. Hadley -- http://had.co.nz/
Reasonably Related Threads
- When adding a record in console, a parameter comes in as null even when I set it
- How do you do a custom sql call in rails?
- CanCan issue when being very specific
- update_attribute does not update
- Using set_primary_key breaks acts_as_tree with non-integer column