I want to create what I think is a loop in R, simplifying code that follows this pattern:
n1<-n + 10
n2<-n1 + 10
n3<-n2 + 10
etc...
However I'm not quite sure how to do this- I know it's not a 'for', 'while', or 'repeat' loop as those are based on true/false outputs whereas here I need the loop to run of outputs from earlier iterations of the loop. Then following on from this is it possible to create this simplified loop with a periodic change? e.g.
n1<-n + 10
n2<-n1 + 10
n3<-n2 + 10 +5
n4<-n3 + 10
n5<-n4 + 10
n6<-n5 + 10 +5
etc...
So every third iteration has an additional input. Feel free to redirect me if this has been asked before. I'm not sure the term 'loop' is right for this but I haven't known what else to search. Any help would be much appreciated!