Re: [Rd] function remains loaded in the search space after detaching the package

From: Uwe Ligges <ligges_at_statistik.tu-dortmund.de>
Date: Fri, 24 Feb 2012 17:08:59 +0100

On 24.02.2012 16:55, Joris Meys wrote:
> Maybe I should rephrase:
>
> As mentioned by Martin, by you and by TFM (which I read),
> unloadNamespaces does not remove registered S3 methods. I got the
> message before. As to why it has to be this way, the people that WTFM
> didn't really add much information to TFM for those who RTFM (nor do
> they have to). I merely wondered why it had to be that way out of
> interest, but maybe formulated my question in a less clear and more
> offensive way.
>
> So:
>
> Given the fact that S3 methods are not removed by unloading a namespace:
>
> - What is the reason for this, as I would naively assume removing
> them when unloading a namespace seems more useful?

Because there are no mechanisms implemented that keep the old information, i.e. before things got registered.

> - How do you remove them without having to restart R?

That is not possible.

Uwe Ligges

> Sincerely,
> Joris
>
> 2012/2/24 Prof Brian Ripley<ripley_at_stats.ox.ac.uk>:
>> fortunes::fortune('WTFM') applies. As already pointed out, ?detach says
>>
>> If a package has a namespace, detaching it does not by default
>> unload the namespace (and may not even with ‘unload=TRUE’), and
>> detaching will not in general unload any dynamically loaded
>> compiled code (DLLs). Further, registered S3 methods from the
>> namespace will not be removed. If you use ‘library’ on a package
>> whose namespace is loaded, it attaches the exports of the already
>> loaded namespace. So detaching and re-attaching a package may not
>> refresh some or all components of the package, and is inadvisable.
>>
>> And that is explicitly mentioned on ?unloadNamespace ....
>>
>>
>> On Fri, 24 Feb 2012, Joris Meys wrote:
>>
>>> 2012/2/24 Prof Brian Ripley<ripley_at_stats.ox.ac.uk>:
>>>>
>>>>
>>>> As
>>>>
>>>> getS3method('print', 'object_size')
>>>>
>>>> would have confirmed the expectations of a 'one' with a less sketchy
>>>> understanding of R.
>>>>
>>> Yes, getS3method() sends you -not very surprisingly- to the one from
>>> gdata. I realized, as print(object.size(iris)) gets that one as well,
>>> and even in my sketchy understanding of R I suspect that both actions
>>> have a similar underlying mechanism. But that's not my point.
>>>
>>> Why would I have to expect the gdata version is still used (under the
>>> correct assumption that I haven't been writing on the R source code
>>> myself)? As a maybe-not-so-smart basic user of R, I would expect that
>>> detach() and eventually unloadNamespace() would revert the effect of
>>> library() (and loadNamespace() ). Apparently they don't.
>>>
>>> The only way to reverse the action of require(gdata) seems to be to
>>> restart R. That's at least what my limited brain could understand from
>>> the valuable information given by both you and Martin. Seemingly
>>> having to restart an application to undo an action, even in the
>>> presence of functions with names that make you believe they revert a
>>> former action, might in general be conceived as rather unexpected by
>>> somebody with the same sketchy understanding of R as me. I would be
>>> delighted if you could explain to me which part of R I understand
>>> wrongly to come to this silly observation.
>>
>>
>>>
>>> Sincerely,
>>> Joris
>>>
>>>
>>>
>>> --
>>> Joris Meys
>>> Statistical consultant
>>>
>>> Ghent University
>>> Faculty of Bioscience Engineering
>>> Department of Mathematical Modelling, Statistics and Bio-Informatics
>>>
>>> tel : +32 9 264 59 87
>>> Joris.Meys_at_Ugent.be
>>> -------------------------------
>>> Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php
>>>
>>
>> --
>> Brian D. Ripley, ripley_at_stats.ox.ac.uk
>> Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
>> University of Oxford, Tel: +44 1865 272861 (self)
>> 1 South Parks Road, +44 1865 272866 (PA)
>> Oxford OX1 3TG, UK Fax: +44 1865 272595
>
>
>



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Fri 24 Feb 2012 - 16:10:55 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 24 Feb 2012 - 17:50:20 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive