Skip to content
Prev 24699 / 63424 Next

sys.call and friends

Hello,


I noticed that sys.frame treats which = 0 differently than sys.call and 
sys.function, and the documentation was unclear about it.

 > f <- function() sys.call()
 > f()
f()
 > f <- function() sys.function()
 > f()
function() sys.function()
 > f <- function() sys.frame()
 > f()
<environment: R_GlobalEnv>

sys.frame(0) always returns the .GlobalEnv, while sys.call(0) and 
sys.function(0) return the current call and function definition.

I offer a patch to clarify this for the uninitiated.

 > sessionInfo()
R version 2.6.0 Under development (unstable) (2007-04-16 r41194)
i686-pc-linux-gnu

locale:
LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=en_US.UTF-8;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C

attached base packages:
[1] "stats"     "graphics"  "grDevices" "utils"     "datasets"  "methods"
[7] "base"

Jeff