Given the following, how to I get x[i+1] to not return an NA result when it gets to the end of list x by looping back to the start of the list i.e should return: 0 0 2 2 2 2?
> x<-c(2,0,0,2,2,2) > i<-1:length(x) > x[i] [1] 2 0 0 2 2 2 > x[i+1] [1] 0 0 2 2 2 NA can i be described using a loop that says go back to the beginning of list x? -- View this message in context: http://r.789695.n4.nabble.com/creating-a-closed-loop-for-a-list-tp4221333p4221333.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.