
288 R Programming for Bioinformatics
Now we will use trace to debug the subsetAsCharacter generic only when
x is of class "character".
> trace("subsetAsCharacter", tracer = browser,
signature=c(x = "numeric"))
[1] "subsetAsCharacter"
Note that, in this particular case, there was no specific subsetAsCharacter
metho d with this signature. So the tracing will occur for the default metho d
— but only when the signature matches the one given to trace.
> subsetAsCharacter(1.5, 1:2)
Tracing subsetAsCharacter(1.5, 1:2) on entry
Called from: subsetAsCharacter(1.5, 1:2)
Browse[1]> ls()
[1] "i" "j" "x"
Browse[1]> x
[1] 1.5
Browse[1]> c
[1] "1.5" NA
> subsetAsCharacter(1 ...