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 ______________________________________________ [email protected] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
