34 2946 2010 2.251
-Original Message-
From: arun [mailto:smartpink...@yahoo.com]
Sent: Tuesday, October 30, 2012 1:57 PM
To: Meredith, Christy S -FS
Cc: R help; William Dunlap
Subject: Re: [R] help with for loop: new column giving count of observation for
each SITEID
HI,
You c
Message -
> From: William Dunlap
> To: "Meredith, Christy S -FS"
> Cc: "r-help@r-project.org"
> Sent: Tuesday, October 30, 2012 3:43 PM
> Subject: Re: [R] help with for loop: new column giving count of observation
> for each SITEID
>
> Your data w
;
Cc: "r-help@r-project.org"
Sent: Tuesday, October 30, 2012 3:43 PM
Subject: Re: [R] help with for loop: new column giving count of observation for
each SITEID
Your data was, in R-readable format (from dput())
d <- data.frame(
RchID = 1:9,
site = factor(c(&qu
20021
> 8 C 20032
> 9 C 20043
>
>
> Thanks so much for you help!
>
> -Original Message-
> From: William Dunlap [mailto:wdun...@tibco.com]
> Sent: Tuesday, October 30, 2012 1:07 PM
> To: Meredith, Christy S -FS; r-help@R-proje
Software
wdunlap tibco.com
> -----Original Message-----
> From: Meredith, Christy S -FS [mailto:csmered...@fs.fed.us]
> Sent: Tuesday, October 30, 2012 12:20 PM
> To: William Dunlap
> Subject: RE: [R] help with for loop: new column giving count of observation
> for each
>
, Christy S -FS; r-help@R-project.org
Subject: RE: [R] help with for loop: new column giving count of observation for
each SITEID
Is this what you want?
> withinGroupIndex <- function(group, ...) ave(integer(length(group)), group,
..., FUN=seq_along)
> site <- c("A",
Is this what you want?
> withinGroupIndex <- function(group, ...) ave(integer(length(group)), group,
..., FUN=seq_along)
> site <- c("A","A","C","D","C","A","B")
> data.frame(site, index=withinGroupIndex(site))
site index
1A 1
2A 2
3C 1
4D 1
5
7 matches
Mail list logo