[R] data manipulation help

From: roberto munguia <munguiar_at_posgrado.ecologia.edu.mx>
Date: Tue 16 Aug 2005 - 13:05:27 EST


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]]



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Tue Aug 16 13:14:32 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:39:49 EST