Rprof

Rprof(filename)
Examine which commands are taking up the most time in an R script or function. I’d call this a crapshoot since Rprof doesn’t typically indicate a particular line of code that is taking a disproportionate amount of time. However, Rprof is easy and quick to implement, so it may serve as a nice first attempt to identify what is making code run slowly.
  • filename – A file name where to store results.

Continue reading

message

message(…)
Create a diagnostic message, often from within a function, where the text output is red.
  • – A series of arguments that can be coerced into character strings. These arguments will be pasted together with no separator and then output in red.

Continue reading

on.exit

on.exit(expr)
The on.exit function is used within other functions to specify a command to be run when exiting the parent function. For instance, if plotting parameters are automatically adjusted in a function, use on.exit to adjust plotting parameters back to their original settings.
  • expr – An R expression or command.

Continue reading

warning, stop

Use these functions to return a warning or error from another function. The warning function will output a message after a function finishes, while the stop function both stops the execution of the function and outputs an error message.
warning(char)
  • char – A character string that is output to the user.
stop(char)
  • char – A character string that is output to the user.

Continue reading

debug, undebug

Use debug to put a function into debugging mode. When a function is in debugging mode, the function’s commands are run one at a time, and the function only moves onto the next command when told to do so. Between each of these function commands, the variables within the function are accessible and other commands may be run, making it easy to check the values of variables, change those values, or run other commands. To take a function out of debugging mode, use the undebug function.
debug(fun)
  • fun – A function.
undebug(fun)
  • fun – A function.

Continue reading