Primary exercises
- Simple expression.
Calculate 25 plus the square of 12.
25 + 12^2
[1] 169
- Calling a function.
What is the square root of the number you have just calculated (here
type the number directly)?
sqrt( 25 + 12^2 )
[1] 13
- 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.
# To stop in the console press: Esc or Ctrl-C
# To clear in the console press: Ctrl-L
- 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
.
# (1+2)*(3+4)) -> forgotten (
# 0,25 -> use dot as decimal point: 0.25
# sin() -> sin needs an argument
# xyz -> xyz is a name not known to R
- Getting help.
Find the manual page for the sin
function.
# In the console type: ?sin
Copyright © 2023 Biomedical Data Sciences (BDS) | LUMC