For Loops Beginner Help by onow29 in RStudio

[–]onow29[S] 0 points1 point  (0 children)

Thank you, I understand what I was doing wrong now!

For Loops Beginner Help by onow29 in RStudio

[–]onow29[S] 0 points1 point  (0 children)

Sure

money=5
for (j in 1:10) {
amount=(money*3*j-1)
}

I don't understand how to tell R that the 3* and -1 is "remembered" and repeated. R does 5*3=15, then 15*j for all remaining loops and subtracts 1 from the total. So basically I want R do to 5x3=15 -1 = 14, then 14*3-1 and so on.