Skip to content
Prev 176447 / 398503 Next

Sequences

On Tue, 2009-04-07 at 05:16 -0700, Melissa2k9 wrote:
Hi Melissa,

I think this is a index problem ...

your code is:

s<-rep(0,207)   
s<-as.vector(s)
s[0]<-0
for (i in 1:length(lambs)){
        s[i]<-s[i-1]-mean(lambs)
}

But try this code:

s<-rep(0,207)   
s<-as.vector(s)
s[1]<-0 # not s[0]
for (i in 2:length(lambs)){ #not 1:length(lambs)
        s[i]<-s[i-1]-mean(lambs)
}

The vector in R begin in 1 not in 0...