Learn R Programming

Hmisc (version 5.2-3)

Fdebug: Debug Printing Function Generator

Description

Takes the name of a system options(opt=) and checks to see if option opt is set to TRUE, taking its default value to be FALSE. If TRUE, a function is created that calls prn() to print an object with the object's name in the description along with the option name and the name of the function within which the generated function was called, if any. If option opt is not set, a dummy function is generated instead. If options(debug_file=) is set when the generated function is called, prn() output will be appended to that file name instead of the console. At any time, set options(debug_file='') to resume printing to the console.

Usage

Fdebug(opt)

Value

a function

Arguments

opt

character string containing an option name

Author

Fran Harrell

Examples

Run this code
dfun <- Fdebug('my_option_name')   # my_option_name not currently set
dfun
dfun(sqrt(2))
options(my_option_name=TRUE)
dfun <- Fdebug('my_option_name')
dfun
dfun(sqrt(2))
# options(debug_file='/tmp/z') to append output to /tmp/z
options(my_option_name=NULL)

Run the code above in your browser using DataLab