From Waclaw.Marcin.Kusnierczyk at idi.ntnu.no  Tue Feb 10 15:02:20 2009
From: Waclaw.Marcin.Kusnierczyk at idi.ntnu.no (Wacek Kusnierczyk)
Date: Tue, 10 Feb 2009 15:02:20 +0100
Subject: [Rd] Bug in subsetting data frame (PR#13515)
In-Reply-To: <499182F8.7000507@idi.ntnu.no>
References: <20090210102506.CB966282EF48@mail.pubhealth.ku.dk>	<8b356f880902100459n321c321ew1ee4ab3c9a7ddb0f@mail.gmail.com>
	<499182F8.7000507@idi.ntnu.no>
Message-ID: <499188EC.7050700@idi.ntnu.no>

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



[Rd] Bug in subsetting data frame (PR#13515)
Wacek Kusnierczyk