Re: [Rd] Bug in subsetting data frame (PR#13515)

From: Wacek Kusnierczyk <Waclaw.Marcin.Kusnierczyk_at_idi.ntnu.no>
Date: Tue, 10 Feb 2009 15:02:20 +0100

Wacek Kusnierczyk wrote:
> Stavros Macrakis wrote:
>
>> Don't know if this is the problem, but....
>>
>> It is a bad idea to set data.frame <- xxx since R has a single
>> namespace for functions and variables.
>>
>>
>>
>
>
> the issue is, if you use a name as an operator, it's the first *function
> value*, not just *value*, found on the search path that will be used.
> in the example you referred to, if you assign a non-function value to
> data.frame, an attempt to apply data.frame will get the function from
> package:base:
>
> data.frame = 0
> find('data.frame')
> find('data.frame', mode='function')
>

... but if you really need to modify data.frame in place, you can:

pos = grep('^package:base$', search())
unlockBinding('data.frame', as.environment(pos)) assign('data.frame', function(...) NULL, as.environment(pos)) lockBinding('data.frame', as.environment(pos))

vQ



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Tue 10 Feb 2009 - 13:05:24 GMT

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 Tue 10 Feb 2009 - 13:30:22 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