[R] Adapting R code for different traps

bjmjarrett bjmjarrett at gmail.com
Thu Jun 9 13:22:20 CEST 2011


Hi all,

My code:

> temp<-outer(release.days,collection.days,'-')
> temp<-ifelse(temp>=0,NA,temp)
> release.diff<-apply(temp,2,max,na.rm=TRUE)

works for one trap and does what I want. That is, it determines the time
difference between the collection date of a trap and date of parasitoid
release immediately before it, excluding releases that occurred on the same
day as the collection.

The code above, however, does not give the correct values - those that I
have calculated for each trap individually. I am wondering how I can adapt
this code for each trap ie. it uses only data associated with a particular
trap ID. 

For instance:

> temp<-outer(release.days[Trap],collection.days.2[Trap],'-')
> temp<-ifelse(temp>=0,NA,temp)
> release.diff.1<-apply(temp,2,max,na.rm=TRUE)

calculates the same value for each trap, irrespective of collection day.

Thanks in advance

Ben


--
View this message in context: http://r.789695.n4.nabble.com/Adapting-R-code-for-different-traps-tp3585215p3585215.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list