An embedded and charset-unspecified text was scrubbed... Name: not available Url: https://stat.ethz.ch/pipermail/r-help/attachments/20050815/d955a96f/attachment.pl
data manipulation help
2 messages · roberto munguia, Dieter Menne
roberto munguia <munguiar <at> posgrado.ecologia.edu.mx> writes:
I have a dataframe with 468 individuals (rows) that I captured at least once during 28 visits (columns), it looks like: mortality[1:10,] 1 1 0 0 0 1 1 1 0 0 0
..
so I can know how many times every individual was captured, 0= not capture, 1=capture.
I also want to know when was the first and the last capture for every individual,
This should give you a starter # create play data cap = data.frame(matrix(rbinom(120,1,0.3),nrow=10)) firstthat<-function(x) which(x)[1] # stolen from Thomas Lumley # Make your data logical; not really needed, but easier to understand cap.log = cap==1 apply(cap.log,1,firstthat) # gives first captures Dieter