[prev in list] [next in list] [prev in thread] [next in thread]
List: r-devel
Subject: Re: [Rd] what should NCOL(NULL) return?
From: Tony Plate <tplate () acm ! org>
Date: 2009-10-29 15:14:59
Message-ID: 4AE9B173.7080304 () acm ! org
[Download RAW message or body]
Hiroyuki Kawakatsu wrote:
> Hi,
>
> I get (using r50188)
>
>
>> nrow(NULL)
>>
> NULL
>
>> NROW(NULL)
>>
> [1] 0
>
>> ncol(NULL)
>>
> NULL
>
>> NCOL(NULL)
>>
> [1] 1
>
> The last seems 'wrong' to me, though matrix(NA, 0, 1) appears to be
> well defined.
>
Seems consistent with the documentation, which says:
Description
|nrow| and |ncol| return the number of rows or columns present in |x|.
|NCOL| and |NROW| do the same treating a vector as 1-column matrix.
Based on ?NCOL alone, I guess one might be able to quibble about how
NULL should be treated, as the docs do describe the argument as "x a
vector, array or data frame." However, it's pretty common for functions
that work with vectors and arrays to treat NULL the same as numeric(0).
-- Tony Plate
>
>> blackhole = matrix(NA, 0, 1)
>> blackhole[,1] = 5
>> blackhole
>>
> [,1]
>
> h.
>
______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic