On Mon, Feb 9, 2009 at 8:03 AM, clion wrote:
>
> this is good, but it doesn't solve my main problem (which I unfortunately
> din't post - very sorry )
> I would like to filter may data , for example by:
>
> dat.sub<-dat[dat$age>10 & dat$NoCaps>2,]
>
> So I need a column where the number of Captur
this is good, but it doesn't solve my main problem (which I unfortunately
din't post - very sorry )
I would like to filter may data , for example by:
dat.sub<-dat[dat$age>10 & dat$NoCaps>2,]
So I need a column where the number of Captures is repeated for all rows of
each captured animal.
(or is
in this case you can use ave(), e.g., say 'dat' is the name of your data
frame, then try this:
dat$NoCaps <- ave(dat$Id, dat$Id, FUN = length)
dat
I hope it helps.
Best,
Dimitris
clion wrote:
Hi there.
I collectad data of several animals (Id) that were caught and measured at
several occasi
This should do it for you:
> x <- read.table('clipboard', header=TRUE)
> x
Id age mass
1 1 1 5.4
2 1 3 6.2
3 1 15 10.0
4 2 3 8.1
5 2 10 12.8
6 3 2 5.9
7 3 10 7.1
8 3 15 15.4
9 3 17 16.2
> x$NoCap <- ave(x$Id, x$Id, FUN=length)
> x
Id age mass NoCap
1 1 1 5.4
Hi there.
I collectad data of several animals (Id) that were caught and measured at
several occasions.
The dataframe looks like this:
Grouped Data: mass ~ age | Id
Id age mass
11 5.4
13 6.2
1 15 10.0
23 8.1
2 10
5 matches
Mail list logo