From cberry at tajo.ucsd.edu  Thu Oct 27 00:37:07 2005
From: cberry at tajo.ucsd.edu (Charles C. Berry)
Date: Wed, 26 Oct 2005 15:37:07 -0700
Subject: [Rd] unexpected '[<-.data.frame' result
In-Reply-To: <x2irvk6n5v.fsf@turmalin.kubism.ku.dk>
References: <Pine.LNX.4.63.0510261142050.11780@tajo.ucsd.edu>
	<x2irvk6n5v.fsf@turmalin.kubism.ku.dk>
Message-ID: <Pine.LNX.4.63.0510261526530.11780@tajo.ucsd.edu>

On Wed, 26 Oct 2005, Peter Dalgaard wrote:

> "Charles C. Berry" <cberry at tajo.ucsd.edu> writes:
>
>> Is this a bug?
>>
>> If not, I am curious to know why '[<-.data.frame' was designed to yield
>> a.frame$y != a.frame$z rather than refusing to carry out the operation at
>> all.
>>
>>> a.frame <- data.frame( x=letters[1:5] )
>>> a.frame[ 2:5, "y" ] <- letters[2:5]
>>> a.frame[[ "z" ]][ 2:5 ] <- letters[2:5]
>>> a.frame
>>    x    y    z
>> 1 a    b <NA>
>> 2 b    c    b
>> 3 c    d    c
>> 4 d    e    d
>> 5 e <NA>    e
>
> It sure looks like a bug, and we're not even prototype-compatible:
>

[stuff deleted]

>
> Why would you expect the operation to be refused?
>

I was having trouble deciding if the use of "whole" in the 
Extract.data.frame help page was a warning against creating columns with 
only some entries present:

 	"The replacement methods can be used to add whole column(s)..."

[rest deleted]

Charles C. Berry                        (858) 534-2098
                                          Dept of Family/Preventive Medicine
E mailto:cberry at tajo.ucsd.edu	         UC San Diego
http://biostat.ucsd.edu/~cberry/         La Jolla, San Diego 92093-0717



[Rd] unexpected '[<-.data.frame' result
Charles C. Berry