Working with functions
Benchmark code
system.time(mean(1:10^7))
## user system elapsed
## 0.044 0.011 0.056
Inform users with a message
message('Hello world')
## Hello world
Abort execution and return error message
stop('Something went wrong')
> Error: Something went wrong
Do not abort code if error is returned
try(log("you can't log a string"))
Suppress messages
# When using a function
suppressMessages(expr)
# When loading libraries
suppressPackageStartupMessages( library(ggplot2) )