Hellow everybody,

 

I have a dataframe with 468 individuals (rows) that I captured at least once
during 28 visits (columns), it looks like:

 

mortality[1:10,]

 

   X18.10.2004 X20.10.2004 X22.10.2004 X24.10.2004 X26.10.2004 X28.10.2004
X30.10.2004 X01.11.2004 X03.11.2004 X07.11.2004

1            1           0           0           0           1           1
1           0           0           0

2            1           0           0           0           0           0
0           0           0           0

3            1           1           1           0           0           0
1           0           0           1

4            1           0           0           0           0           0
0           0           0           0

5            1           1           1           1           0           0
1           1           0           0

6            1           1           1           1           0           0
0           1           0           0

7            1           0           1           0           1           0
1           1           0           0

8            1           1           1           0           1           0
1           1           1           1

9            1           0           0           1           1           0
0           0           1           0

10           1           0           1           0           1           0
0           0           0           0

 

 

so I can know how many times every individual was captured, 0= not capture,
1=capture. 

 

persistence<-apply(mortacap2,1,sum)

 

I also want to know when  was the first and the last capture for every
individual,

 

if I use:

 

which(mortacap2[1,]==1)

 

X18.10.2004 X26.10.2004 X28.10.2004 X30.10.2004 

          1           5           6           7 

 

I can estimate manually row by row, but I dont get how to estimate the first
and the last capture,

to all individuals in the database at the same time.

 

I tried 

 

d<-numeric(368)

for (i in 1:368) {d[i]<-which(mortacap2[1:368,]==1}

 

but it didnt work. Any help would be appreciated.

 

Thanks in advance!!

 

Roberto Munguia Steyer

Departamento Biologia Evolutiva

Instituto de Ecologia, A.C.

Xalapa, Veracruz.

MEXICO

 

Windows XP

R 2.10


	[[alternative HTML version deleted]]


