The goal of this practical is to familiarize yourself with R and the RStudio environment.
The objectives of this session will be to:
is a programming language and free software environment for statistical computing and graphics supported by the R Foundation for Statistical Computing.
Reasons to use
It’s free, well documented, and runs almost everywhere
it has a large (and growing) user base among scientists
it has a large library of external packages available for performing diverse tasks.
15,068 available packages on https://cran.r-project.org/
3,087 available packages on http://www.bioconductor.org
122,720 available repository on https://github.com/
+
/
*
-
^
or **
(
, )
(3 + (5 * (2 ^ 2))) # hard to read
3 + 5 * 2 ^ 2 # clear, if you remember the rules
3 + 5 * (2 ^ 2) # if you forget some rules, this might help
2e-4
is shorthand for 2 * 10^(-4)
Compute the factorial of 9
equality (note two equal signs read as “is equal to”)
inequality (read as “is not equal to”)
less than
less than or equal to
greater than
<-
is the assignment operator in R. (read as left member take right member value)
Variable names can contain letters, numbers, underscores and periods.
They cannot start with a number nor contain spaces at all.
Different people use different conventions for long variable names, these include
What you use is up to you, but be consistent.
It is also possible to use the =
operator for assignment but don’t do it !
Which of the following are valid R variable names?
min_height
max.height
_age
.mass
MaxLength
min-length
2widths
celsius2kelvin
A R function can have different arguments
base
is a named argument are read from left to rightTo know more about the log
function we can read its manual.
Test that your logarithm
function can work in base 10