[R] [Rd] is.matrix

Wacek Kusnierczyk Waclaw.Marcin.Kusnierczyk at idi.ntnu.no
Tue Nov 11 21:10:57 CET 2008


hadley wickham wrote:
> On Tue, Nov 11, 2008 at 1:58 PM, Wacek Kusnierczyk
> <Waclaw.Marcin.Kusnierczyk at idi.ntnu.no> wrote:
>   
>> hadley wickham wrote:
>>     
>>> On Tue, Nov 11, 2008 at 1:42 PM, Wacek Kusnierczyk
>>> <Waclaw.Marcin.Kusnierczyk at idi.ntnu.no> wrote:
>>>
>>>       
>>>> hadley wickham wrote:
>>>>
>>>>         
>>>>>> |  is.matrix| returns |TRUE| if |x| is a matrix and has a |dim <dim.html>|
>>>>>> attribute of length 2) and |FALSE| otherwise
>>>>>>
>>>>>>
>>>>>>             
>>>>> That's confusing!  In what situations is x a matrix but does not have
>>>>> a dim attribute?
>>>>>
>>>>>
>>>>>
>>>>>           
>>>> x = matrix(1,1,1)
>>>> dim(x) = c(1,1,1)
>>>>
>>>>         
>>> I think you meant
>>> dim(x) <- c(3, 1)
>>>
>>> You created a 1 x 1 x 1 array.
>>>
>>>       
>> i know, that's precisely what i wanted.  this is a simple 3d structure,
>> yet is(x) reveals it is a matrix.  that was the point.
>>     
>
> I think the message here is not to use is().  is() is designed for use
> with S4 objects, and it doesn't always give what you'd expect for
> primitive objects.  
fine if it could issue a warning when used in conflict with the message.

vQ



More information about the R-help mailing list