[R] Noob question re: writing while loops on one line

Sun Shine phaedrusv at gmail.com
Sun Feb 15 11:20:50 CET 2015


Hi list

I'm working through some exercises and did a while loop which raised an 
issue for me:

I can write out the while loop so:

 > count <- 0

while(count < 10) {
     print(count)
     count <- count + 1
    }

And this works fine.

Trying to do the same thing all on one line however gives this error:

"Error: unexpected symbol in "while(count < 10) { print(count) count""

My question:

How can one write out a while loop all in one line? Is there a symbol or 
something that I should be including?

Thanks for any suggestions.

Sun



More information about the R-help mailing list