Skip to content

On "^" returning a matrix when operated on a data.frame

4 messages · Duncan Murdoch, Arunkumar Srinivasan

#
On 13-11-13 6:00 PM, Arunkumar Srinivasan wrote:
It's not just ^ that is missing, the logical relations like <, ==, etc 
also return matrices.  This is very old code (I think from 1999), but I 
would guess that the reason is that the ^ and < operators always return 
values of a single type (numeric and logical respectively), whereas the 
other operators can take mixed type inputs and return mixed type outputs.

Duncan Murdoch
#
On 13-11-13 6:52 PM, Arunkumar Srinivasan wrote:
You're right, "/", "%/%" and "%%" also return consistent types.  So my 
explanation is wrong.  The NEWS entry for this change appears to be in 
the 0.63 release,

     o	Ops.data.frame :  things like  d.fr < a	  now return a matrix

That doesn't give much of a hint for why "^" is handled differently than 
"/".

Duncan Murdoch