R-Basic Part V: Control Structures, Scoping in R, Dates and Times
Highlights: If-else expression For-loop, While-loop, and Repeat-loop Writing a Function and Return Value Lexical vs. Dynamic Scoping Dates and Times in R Control Structures in R Control structures in R allow us to control the flow of R program. Below is a list of some common basic constructs and a brief description of their jobs. if, else: testing a logical condition for: executing a loop certain number of times while: executing a loop until a condition remains true repeat: executing an infinite loop break: breaking the execution of a loop next: skips an iteration of a function return: exit a function If-else I f combined with e l s e allows programmers to test logical conditions and let R do something based on whether is true or false. The e l s e part is optional, so, it is used if we want R to do something else given the defined condition is not met. There are three types of conditional in this ...