[R] Infelicity in print output with matrix indexing of `[.data.frame`
Jeff Newmiller
jdnewmil at dcn.davis.ca.us
Sun Dec 18 00:15:32 CET 2016
No, cannot agree. The result of using an n by 2 matrix to index into a rectangular object is a vector. A vector can only have one storage mode for all elements. Some type coercion is necessary to accommodate this.
--
Sent from my phone. Please excuse my brevity.
On December 17, 2016 2:58:24 PM PST, David Winsemius <dwinsemius at comcast.net> wrote:
>
>> On Dec 17, 2016, at 11:34 AM, Bert Gunter <bgunter.4567 at gmail.com>
>wrote:
>>
>> It's documented, David:
>>
>> From ?"[.data.frame"
>>
>> "Matrix indexing (x[i] with a logical or a 2-column integer matrix i)
>> using [ is not recommended. For extraction, x is first coerced to a
>> matrix..."
>>
>> ergo characters for a mixed mode frame.
>
>Can we agree that it is most ironic that `[<-.data.frame` does not
>impose coercion on its `x` argument with a 2 column matrix as `i`, but
>that `[.data.frame` does? I had initially assumed that the coercion had
>occurred at the time of assignment which would have made more sense (to
>me, anyway).
More information about the R-help
mailing list