help,
Monica
> Date: Thu, 12 Feb 2009 14:05:44 -0800
> From: spec...@stat.berkeley.edu
> To: pisican...@hotmail.com
> CC: christos.hat...@nuverabio.com; r-help@r-project.org; markle...@verizon.net
> Subject: Re: [R] Aggregrate function
>
> Monica -
> Here's a more c
Actually what was originally requested is returned by:
xveg[xveg$tot %in% with(xveg, tapply(tot, loc, max)), c("loc","sp")]
--
David Winsemius
On Feb 12, 2009, at 5:59 PM, markle...@verizon.net wrote:
it does and you get exactly what monica wanted if you take out the
"sp and just return t
I realized later that the which might not be necessary (and in
addition was reminded privately). The %in% function returns a logical
vector which works just as well with matrix or dataframe indexing as
the numeric vector returned by which.
--
David Winsemius
On Feb 12, 2009, at 5:52 PM, D
it does and you get exactly what monica wanted if you take out the "sp
and just return the whole thing. thanks.
On Thu, Feb 12, 2009 at 5:52 PM, David Winsemius wrote:
aggregate and by are convenience functions of tapply.
Consider this alternate solution:
xveg[which(xveg$tot %in% with(xv
aggregate and by are convenience functions of tapply.
Consider this alternate solution:
xveg[which(xveg$tot %in% with(xveg, tapply(tot, loc, max))),"sp"]
It uses tapply to find the maximums by loc(ations) and then to goes
back into xveg to find the corresponding sp(ecies). You should do
testing
d,temp)
print(result)
Thanks so much again,
Monica
From: christos.hat...@nuverabio.com
To: pisican...@hotmail.com; r-help@r-project.org
Subject: RE: [R] Aggregrate function
Date: Thu, 12 Feb 2009 15:56:38 -0500
I don't have an easy solution with aggregate, because the function in
a
-Christos
> -Original Message-
> From: Monica Pisica [mailto:pisican...@hotmail.com]
> Sent: Thursday, February 12, 2009 4:35 PM
> To: christos.hat...@nuverabio.com; R help project;
> markle...@verizon.net
> Subject: RE: [R] Aggregrate function
>
>
> Hi,
>
&g
,sp=paste(.df$sp[maxindices],collapse=","),tot=max(.df$tot))
})
result <- do.call(rbind,temp)
print(result)
Thanks so much again,
Monica
> From: christos.hat...@nuverabio.com
> To: pisican...@hotmail.com; r-help@r-project.org
> Subject: RE: [R] Aggregrate function
&g
I don't have an easy solution with aggregate, because the function in
aggregate needs to return a scalar.
But the following should work:
do.call("rbind", lapply(split(xveg, xveg$loc), function(x)
x[which.max(x$tot), ]))
loc sp tot
L1 L1 b 60
L2 L2 e 30
L3 L3 b 68
-Christos
> -O
Dear Monica,
Try this
xveg[with(xveg, tot %in% tapply(tot,loc,max)),]
HTH,
Jorge
On Thu, Feb 12, 2009 at 1:58 PM, Monica Pisica wrote:
>
> Hi,
>
> I have to recognize that i don't fully understand the aggregate function,
> but i think it should help me with what i want to do.
>
> xveg is a
10 matches
Mail list logo