[Rd] Deprecating partial matching in $.data.frame
hpages at fhcrc.org
Fri Mar 22 16:43:21 CET 2013
On 03/22/2013 01:31 AM, peter dalgaard wrote:
> On Mar 22, 2013, at 05:57 , Hervé Pagès wrote:
>> Maybe a compromise would be to just issue a warning without
>> deprecating? That way people who want to do anova(fit1)$P can
>> still do it. When working interactively, it's certainly convenient
>> (serious code however should probably stay away from partial matching).
> That's what it does. Issuing a warning when users do X is pretty much equivalent to deprecating X.
For now yes. But you won't keep it deprecated forever right?
>> And so you keep the semantic consistent with lists because yes,
>> consistency is important. data.frame inherits from list so any
>> operation that works on a list is expected to work on a data.frame,
>> preferably the same way (otherwise it will always be a BIG surprise
>> to the user/programmer). For example if I have to maintain someone
>> else code and see something like:
>> bar <- x$bar
>> and I know that 'x' is a list that contains atomic vectors of the
>> same length, I could have some good reasons to want to use a
>> data.frame instead of a list. And I would assume it's safe to
>> modify the code by adding the following line earlier in it:
>> x <- as.data.frame(x)
>> But with the proposed change to $.data.frame, I cannot make this
>> kind of assumption anymore...
> No, but it's only a real problem if the component is not actually called "bar". You could make the same point for environments, but they never allowed partial matching:
A data.fame is a list, not an environment. It would be silly for
me as a programmer to assume that replacing environment 'x' by
data.frame 'x' won't break the code.
>> e <- as.environment(list(barbaric=666))
>  666
Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M1-B514
P.O. Box 19024
Seattle, WA 98109-1024
E-mail: hpages at fhcrc.org
Phone: (206) 667-5791
Fax: (206) 667-1319
More information about the R-devel