mercy!!! ;-)
thanks, everyone. sure beats me trying to reinvent a slower version of the
wheel. came in very handy.
I think it would be nice to see some of these pointers in the "?by" manual
page. not sure who to ask to do this, but maybe this person reads r-help.
/iaw
Ivo Welch (ivo.we
On Mon, Aug 30, 2010 at 3:54 PM, Dennis Murphy wrote:
> Hi:
>
> You've already gotten some good replies re aggregate() and plyr; here are
> two more choices, from packages doBy and data.table, plus the others for
> a contained summary:
>
> key <- c(1,1,1,2,2,2)
> val1 <- rnorm(6)
> indf <- data
Hi:
You've already gotten some good replies re aggregate() and plyr; here are
two more choices, from packages doBy and data.table, plus the others for
a contained summary:
key <- c(1,1,1,2,2,2)
val1 <- rnorm(6)
indf <- data.frame( key, val1)
outdf <- by(indf, indf$key, function(x) c(m=mean(x)
On Aug 30, 2010, at 9:19 AM, ivo welch wrote:
dear R experts:
has someone written a function that returns the results of by() as a
data frame? of course, this can work only if the output of the
function that is an argument to by() is a numerical vector.
presumably, what is now names(byobject
m 1.71 1.41
Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com
> -Original Message-
> From: r-help-boun...@r-project.org
> [mailto:r-help-boun...@r-project.org] On Behalf Of ivo welch
> Sent: Monday, August 30, 2010 6:19 AM
> To: r-help
> Subject: [R] different i
I can definitely recommend the "plyr" package for these sorts of
operations.
http://had.co.nz/plyr/
ivo welch wrote:
dear R experts:
has someone written a function that returns the results of by() as a
data frame? of course, this can work only if the output of the
function that is an argumen
perfect. this is the R way to do it quick and easy. thank you, marc.
(PS, in my earlier example, what I wanted was aggregate( . ~ key,
data=indf, FUN = function(x) c(m=mean(x), s=sd(x))) )
Ivo Welch (ivo.we...@brown.edu, ivo.we...@gmail.com)
On Mon, Aug 30, 2010 at 10:47 AM, Marc Sch
FYI, since R version 2.11.0, aggregate() can return a vector of summary
results, rather than just a scalar:
> aggregate(iris$Sepal.Length, list(Species = iris$Species),
function(x) c(Mean = mean(x), SD = sd(x)))
Speciesx.Mean x.SD
1 setosa 5.006 0.3524897
2 ver
serious?
key <- c(1,1,1,2,2,2)
val1 <- rnorm(6)
indf <- data.frame( key, val1)
outdf <- by(indf, indf$key, function(x) c(m=mean(x), s=sd(x)) )
outdf
indf$key: 1
m.key m.val1 s.key s.val1
1. 0.6005 0. 1.0191
Try this:
as.data.frame(by( indf, indf$charid, function(x) c(m=mean(x), s=sd(x)) ))
On Mon, Aug 30, 2010 at 10:19 AM, ivo welch wrote:
> dear R experts:
>
> has someone written a function that returns the results of by() as a
> data frame? of course, this can work only if the output of the
>
dear R experts:
has someone written a function that returns the results of by() as a
data frame? of course, this can work only if the output of the
function that is an argument to by() is a numerical vector.
presumably, what is now names(byobject) would become a column in the
data frame, and the
11 matches
Mail list logo