[Rd] sys.calls Behaviour
Dario Strbenac
D.Strbenac at garvan.org.au
Mon Feb 28 01:00:07 CET 2011
Hello,
I noticed a difference between S4 methods and ordinary methods for sys.calls(), where it seems to report everything twice for S4 methods. This seems strange. Am I overlooking something ?
> f <- function(x)
+ {
+ g(x)
+ }
>
> g <- function(y)
+ {
+ cat(y, '\n')
+ sys.calls()
+ }
>
> f(5)
5
[[1]]
f(5)
[[2]]
g(x)
>
>
> setGeneric("conv", signature = c("x"), function(x){standardGeneric("conv")})
[1] "conv"
>
> setMethod("conv", "character", function(x)
+ {
+ conv(as.numeric(x))
+ })
[1] "conv"
>
> setMethod("conv", "numeric", function(x)
+ {
+ cat(x, '\n')
+ sys.calls()
+ })
[1] "conv"
>
> conv("5")
5
[[1]]
conv("5")
[[2]]
conv("5")
[[3]]
conv(as.numeric(x))
[[4]]
conv(as.numeric(x))
>
> sessionInfo()
R version 2.12.2 (2011-02-25)
Platform: i386-pc-mingw32/i386 (32-bit)
locale:
[1] LC_COLLATE=English_Australia.1252 LC_CTYPE=English_Australia.1252 LC_MONETARY=English_Australia.1252 LC_NUMERIC=C LC_TIME=English_Australia.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
--------------------------------------
Dario Strbenac
Research Assistant
Cancer Epigenetics
Garvan Institute of Medical Research
Darlinghurst NSW 2010
Australia
More information about the R-devel
mailing list