[R] get() versus getAnywhere()
Duncan Murdoch
murdoch at stats.uwo.ca
Fri Apr 17 12:21:04 CEST 2009
Benjamin Tyner wrote:
> Many thanks Duncan. Perhaps this merits a more explicit note in the
> documentation?
>
The quote I gave is from the documentation. How could it be more explicit?
Duncan Murdoch
> Duncan Murdoch wrote:
>
>> On 4/16/2009 9:52 AM, Benjamin Tyner wrote:
>>
>>> Hi
>>>
>>> Using R 2.8.1. I have list object called "AuxData". Inside a browser(),
>>>
>>> get("AuxData")
>>>
>>> succeeds, while
>>>
>>> getAnywhere("AuxData")
>>>
>>> fails with the error "no object named âAuxDataâ was found". I'm
>>> curious to know if this could be a bug. If yes, I'll try to come up
>>> with a reproducible example.
>>>
>> It's not a bug. getAnywhere doesn't really mean "anywhere", it means
>> "visible on the search path, registered as an S3 method or in a name
>> space but not exported." On the other hand, the browser will show you
>> the local evaluation frame. So I'd expect the browser to be able to
>> see x below, but getAnywhere wouldn't find it, because it's not in one
>> of the places listed above.
>>
>> f <- function(x) {
>> browser()
>> getAnywhere("x")
>> }
>>
>> f(1)
>>
>
>
>
More information about the R-help
mailing list