Re: [R] store results in loop

2015-09-22 Thread Michael Dewey
Dear Nico Comment inline On 22/09/2015 10:36, Nico Gutierrez wrote: Hi All, very rusty in R.. my results get overwritten when try to store within the loop. This my code: ListS=unique(data$Spec) Stat<- numeric(0) for(i in 5){ Is that what you meant? I would have expected something like 1:5

Re: [R] store results in loop

2015-09-22 Thread Jim Lemon
Hi Nico, A bit difficult to see what is happening without the data, but two suggestions: smoothC=mean(SS$Cc[maxC + c(-2:2)],na.rm=TRUE) ... Stat[i]<-Index Jim On Tue, Sep 22, 2015 at 7:36 PM, Nico Gutierrez wrote: > Hi All, > > very rusty in R.. my results get overwritten when try to store wi

[R] store results in loop

2015-09-22 Thread Nico Gutierrez
Hi All, very rusty in R.. my results get overwritten when try to store within the loop. This my code: ListS=unique(data$Spec) Stat<- numeric(0) for(i in 5){ SS=subset(data,data$Spec==ListS[i]) maxC<- which.max(SS$Cc) smoothC=mean(SS$Cc[maxC + c(-2:2)]) currC=tail(SS,1)$Cc Index=currC/smoothC St