Control structures

One step more, in this section you will learn how to control your thinking. Remember the initial example above: "If my sample is of type B-cell, retrieve expression of CD19, else if my sample is of type T-cell, retrieve expression of CD4". Well, if and else are control structures.

R has 8 control structures:

  • if
  • if-else
  • for
  • nested loops
  • while
  • repeat and break
  • next
  • return

AAHHH! Too complicated for me, going back to the bench, see you. Hang on, you already understood the concept in the paragraph above. Using if and else is very intuitive as you saw. The other ones are also very intuitive! Because this class is an introduction, we will cover if, else, for and while only.

Control structures are all of the same form; structure name followed by brackets, with a block of code inside the brackets:

control_structure{
    block of code
} 

That's it! Relax and keep reading. :)

results matching ""

    No results matching ""