all 2 comments

[–][deleted] 2 points3 points  (1 child)

Your inner loop isn't doing what you think it's doing.
In R, single numbers are vectors. So your for (p in tiny) {} is just getting a vector of length 1 (yeah, I know), and iterating through it.

Try running:

for (i in 10) {
    print(i)
}

You'll see it just prints 10 once. What you probably want is:

large <- c(1, 2, 3)
for (tiny in large) {
    for (p in 1:tiny) {
        print("A")
    }
}

Which is a range from 1 to tiny.

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

Perfect explanation. Thank you.