Hi Jim

2014-07-19 8:25 GMT-03:00 Jim Lemon <jim@bitwrit.com.au>:

>
> Hi Vero,
> I think this does what you want, even though it doesn't do it the way
> you describe above.
>
> cla<-runif(506)+
>  rep(c(seq(1,3,length.out=23),seq(3,1,length.out=23)),11)
> obs_time<-paste(rep(1:11,each=46),rep(1:46,11),sep="_")
> t_max<-rep(0,506)
> t_begin<-rep("",11)
> for(year in 1:11) {
>  threshold<-median(cla[(year-1) * 46 + 1:46]) * 1.05
>  max_pos<-(year-1) * 46 + which.max(cla[(year-1)*46+1:46])
>  t_max[max_pos]<-1
>  threshpos<-(year-1) * 46 + 1
>  while(cla[threshpos] < threshold) threshpos <- threshpos + 1
>  cat(threshold,cla[threshpos],max_pos,cla[max_pos],"\n")
>  t_begin[year]<-obs_time[threshpos]
> }
>

Yes, indeed!!! It does the job beautifully!!!
Thanks so much!

I'll now try to adapt it to the 150.000 time series that form my study area
in South Atlantic Ocean :)
Any advice?

Best,
Vero

	[[alternative HTML version deleted]]

