Links
Notes
- Logical Values
TRUE
andFALSE
. They are also aliases asT
andF
.
- Assignment uses the
<-
operator.- e.g.
x <- 10
- Global assignment uses the
<<-
operator.- e.g.
x <<- 10
- e.g.
- e.g.
Sourcing code from a file.
source("file.R")
Listing a directory – list.files()
> list.files() [1] "_dotfiles" "Applications" "bin" … [19] "install" "lib" "Library" …
Vectors
See R/vectors
Functions
You can use help(function)
and example(function)
to get help / examples
about a function.
sum
function.
This function takes a variable number of arguments (and a
keyword argument, na.rm = FALSE
that's not covered here.)
> sum(1, 2, 3, 4, 5) [1] 15 > sum(1:5) [1] 15 # You can pass vectors as individual arguments too. sum(1:3, 1:4) [1] 16 # Or mix vectors and scalars. > sum(1:3, 4, 1:4) [1] 20