_
-r-help-boun...@r-project.org wrote: -
To: "Laura Bethan Thomas [lbt1]" , "r-help@r-project.org"
From: Bert Gunter
Sent by: r-help-boun...@r-project.org
Date: 01/27/2014 07:54PM
Subject: Re: [R] Calculating group means
1. Please cc anything but personal rema
gt; ________
>
>
> -r-help-boun...@r-project.org wrote: -
> To: "Laura Bethan Thomas [lbt1]" , "r-help@r-project.org"
>
> From: Bert Gunter
> Sent by: r-help-boun...@r-project.org
> Date: 01/27/2014 07:54PM
> Subje
1. Please cc anything but personal remarks to the list, not to me.
That will assure better answers.
2. Your query is too vague for me to be sure -- a small reproducible
example of what you'd like would be very helpful here -- but I am
guessing that you want the ?ave function instead of by().
Chee
Lauri Nikkinen wrote:
>
> Suppose I have a following data set.
>
> y1 <- rnorm(20) + 6.8
> y2 <- rnorm(20) + (1:20*1.7 + 1)
> y3 <- rnorm(20) + (1:20*6.7 + 3.7)
> y <- c(y1,y2,y3)
> var1 <- rep(1:5,12)
> z <- rep(1:6,10)
> f <- gl(3,20, labels=paste("lev", 1:3, sep=""))
> d <- data.frame(var1=v
Well, I finally found a roundabout
fun <- function(x, y) sum(x)/max(y)
aggregate(vsid$lev, list(vsid$month, vsid$year), fun, y=by(vsid$date,
vsid$month, function(x) length(unique(x
Thanks,
Lauri
2007/10/2, Lauri Nikkinen <[EMAIL PROTECTED]>:
> Thanks Petr for your kind answer. I got it now b
Thanks Petr for your kind answer. I got it now but it seems that
argument y will not be split by "list(vsid$month, vsid$year)" in the
aggregate function. I should get number of days in each month in the
denominator with "length(unique(y))" but instead I get sum of days in
months in the denominator.
Hi
[EMAIL PROTECTED] napsal dne 02.10.2007 13:19:09:
> Thanks Petr,
>
> Yes, your code seems to work. But when I try to reproduce it with my
> original data set
>
> fun <- function(x, y) sum(x)/length(unique(y))
> aggregate(vsid$lev, list(vsid$month, vsid$yeari), fun,
vsid$lev=vsid$date)
Shal
Thanks Petr,
Yes, your code seems to work. But when I try to reproduce it with my
original data set
fun <- function(x, y) sum(x)/length(unique(y))
aggregate(vsid$lev, list(vsid$month, vsid$yeari), fun, vsid$lev=vsid$date)
I get
Error: syntax error, unexpected EQ_ASSIGN, expecting ',' in
"aggreg
Hi R-users,
Suppose I have a following data set.
y1 <- rnorm(20) + 6.8
y2 <- rnorm(20) + (1:20*1.7 + 1)
y3 <- rnorm(20) + (1:20*6.7 + 3.7)
y <- c(y1,y2,y3)
var1 <- rep(1:5,12)
z <- rep(1:6,10)
f <- gl(3,20, labels=paste("lev", 1:3, sep=""))
d <- data.frame(var1=var1, z=z,y=y, f=f)
Using followin
9 matches
Mail list logo