Hi Karl,
I mainly have data frames. summarize() does not seem to work with multiple
columns from a data frame. Any suggestion? Thanks.
Jun
On Tue, Apr 7, 2009 at 4:49 AM, Karl Ove Hufthammer <
karl.huftham...@math.uib.no> wrote:
> Jun Shen:
>
> > summarize() can apply multiple functions to one
Jun Shen:
> I mainly have data frames. summarize() does not seem to work with multiple
> columns from a data frame. Any suggestion? Thanks.
summarize() *does* work with multiple columns from data frames, but the
function you use must be able to do column-wise calculations. Example:
with(iris, s
Jun Shen:
> summarize() can apply multiple functions to one column
No, summarize() can apply multiple functions to *multiple* columns
(i.e., matrices). That’s one of the advantages of summarize() over
aggregate().
--
Karl Ove Hufthammer
__
R-help@r-
On Apr 6, 2009, at 6:31 PM, Jun Shen wrote:
This is a good example to compare different approaches. My
understanding is
aggregate() can apply one function to multiple columns
summarize() can apply multiple functions to one column
I am not sure if ddply() can actually apply multiple functions
On Mon, Apr 6, 2009 at 5:31 PM, Jun Shen wrote:
> This is a good example to compare different approaches. My understanding is
>
> aggregate() can apply one function to multiple columns
> summarize() can apply multiple functions to one column
> I am not sure if ddply() can actually apply multiple f
This is a good example to compare different approaches. My understanding is
aggregate() can apply one function to multiple columns
summarize() can apply multiple functions to one column
I am not sure if ddply() can actually apply multiple functions to multiple
columns? This is what I would like to
Nice example. Does anyone know if it is possible to use multiple aggregating
functions with the melt/cast functions?
Cheers,
Dylan
On Monday 06 April 2009, Christian wrote:
> A good package for this sort of questions is doBy, too.
>
> library(doBy)
> summaryBy( tpdv + UM + qta ~ Materiale ,dat
A good package for this sort of questions is doBy, too.
library(doBy)
summaryBy( tpdv + UM + qta ~ Materiale ,data=data,FUN=c(sum,length,mean))
regards, Christian
Hi,
I ve been searching a lot in internet..but I can t find a solution
Attached, you find a file.
I need for each (Materiale, tpdv,
calpeda:
> I need for each (Materiale, tpdv, UM) to find sum,avg and count
> My idea was to aggregate for the 3 parameters ..but I don t know how to
> get the numeric value (SUM,COUNT,AVG) I need.
If I have understood what you’re trying to accomplish, this should work:
$ library(Hmisc)
$ d=read.
On Mon, Apr 6, 2009 at 9:34 AM, Stavros Macrakis wrote:
> There are various ways to do this in R.
>
> # sample data
> dd <- data.frame(a=1:10,b=sample(3,10,replace=T),c=sample(3,10,replace=T))
>
> Using the standard built-in functions, you can use:
>
> *** aggregate ***
>
> aggregate(dd,list(b=dd$
Actually, ddply does this perfectly ... I had made a mistake in using
'each'. The correct code is:
ddply(dd,~b+c,function(x)each(count=length,sum=sum,avg=mean)(x$a))
b c count sum avg
1 1 1 2 10 5.00
2 2 1 1 3 3.00
3 3 1 1 10 10.00
4 1 2 2 10 5.00
There are various ways to do this in R.
# sample data
dd <- data.frame(a=1:10,b=sample(3,10,replace=T),c=sample(3,10,replace=T))
Using the standard built-in functions, you can use:
*** aggregate ***
aggregate(dd,list(b=dd$b,c=dd$c),sum)
b c a b c
1 1 1 10 2 2
2 2 1 3 2 1
*** tapply **
I gather you have an SQL background since those are SQL functions.
Check out the sqldf R package and the many examples on the home
page:
http://sqldf.googlecode.com
and in ?sqldf
That may ease the transition from SQL to R.
On Mon, Apr 6, 2009 at 5:37 AM, calpeda wrote:
>
> Hi,
> I ve been sear
13 matches
Mail list logo