From hpages at fhcrc.org  Fri Mar 22 16:43:21 2013
From: hpages at fhcrc.org (=?ISO-8859-1?Q?Herv=E9_Pag=E8s?=)
Date: Fri, 22 Mar 2013 08:43:21 -0700
Subject: [Rd] Deprecating partial matching in $.data.frame
In-Reply-To: <A60359C0-87E8-430A-B76A-1D800A5A00CB@gmail.com>
References: <A0DE2631-213D-4DB2-A952-5DBFA7A7F14C@gmail.com>
	<E66794E69CFDE04D9A70842786030B931B918849@PA-MBX04.na.tibco.com>
	<A3631670-5E8D-48DC-9868-8C9EE8852FE6@gmail.com>
	<CABdHhvHdHnOEyS+MKmwKTQpYp=zsfB84QDND-LRo2Sf4DXrRXA@mail.gmail.com>
	<514AC40E.2080808@gmail.com>
	<9966F1D2-A672-4017-B59D-C05BC86DB603@gmail.com>
	<514BE4D6.105@fhcrc.org>
	<A60359C0-87E8-430A-B76A-1D800A5A00CB@gmail.com>
Message-ID: <514C7C19.3040306@fhcrc.org>

Hi,

On 03/22/2013 01:31 AM, peter dalgaard wrote:
>
> On Mar 22, 2013, at 05:57 , Herv? Pag?s wrote:
>
>> Hi,
>>
>> 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.

H.

>
>> e <- as.environment(list(barbaric=666))
>> e$bar
> NULL
>> e$barbaric
> [1] 666
>
>
>
>

-- 
Herv? Pag?s

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



[Rd] Deprecating partial matching in $.data.frame
=?ISO-8859-1?Q?Herv=E9_Pag=E8s?=