Primary exercises

  1. Simple expression.
    Calculate 25 plus the square of 12.

  2. Calling a function.
    What is the square root of the number you have just calculated (here type the number directly)?

  3. Prompt with +.
    In the console type an incomplete expression (1+2 and press Enter. Practice how to return to the proper console prompt >. Finally, clear the console.

  4. Some error messages.
    In the console type an error expression (1+2)*(3+4)). Understand the error message. Also understand errors reported for expressions: 0,25, sin(), xyz.

  5. Getting help.
    Find the manual page for the sin function.

Extra exercises

  1. Command history.
    In the console try: history(). Locate the History pane and observe what happens when you double-click a line there.
    A save button allows to save typed commands but this is not a practical way to save the code.

  2. Logarithms and exponentials.
    Check the manual to understand the difference between log10( 100 ), log2( 100 ) and log( 100 ).
    Find what would be the result of exp( 1 ) and log( exp( 1 ) ).

  3. Trigonometry.
    Calculate \(cos(90^{\circ})\).
    Remember that in R the trigonometric functions require angles specified in radians (you may use the pi variable).



Copyright © 2022 Biomedical Data Sciences (BDS) | LUMC