Tuesday, 14 July 2015

R: while loop

“while” loop takes a logical expression and execute the statements in the loop, until the logical expression true.

Syntax
while(Logical Expression){
         Do Something
}


WhileEx.R

count <- 0 

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


$ Rscript WhileEx.R 
[1] 0
[1] 1
[1] 2
[1] 3
[1] 4
[1] 5
[1] 6
[1] 7
[1] 8
[1] 9



Prevoius                                                 Next                                                 Home

No comments:

Post a Comment