More useful things…

Important functionality

  • Restarting R
  • Debugging
  • while loops:
    while (...) { ... }

Restarting R

Restart early, restart often… and don’t restore data.

Errors

Errors

Debugging

There are lots of debugging options in R

for (...) loops - recap

Doing something a fixed number of times:

sequence <- seq(from = 0, to = 2, by = 0.5)

for (number in sequence) {
  print(number)
}
[1] 0
[1] 0.5
[1] 1
[1] 1.5
[1] 2

while (...) loops

Doing something until it is finished:

number <- 0
max.number <- 2
increment <- 0.5
while (number <= max.number) {
  print(number)
  number <- number + increment
}
[1] 0
[1] 0.5
[1] 1
[1] 1.5
[1] 2