[Rd] ambiguity in the documented return value of Null() from package MASS
Martin Maechler
maechler at stat.math.ethz.ch
Mon Nov 10 15:12:43 CET 2014
>>>>> peter dalgaard <pdalgd at gmail.com>
>>>>> on Mon, 10 Nov 2014 14:47:16 +0100 writes:
> There is a maintainer for this contributed package...
> However, a zero column vector _is_ numeric(0) -- with
> dimension attributes c(3,0).
> structure(numeric(0),dim=c(3,0))
> c(Null(diag(3)))
> I.e., the ambiguity is pretty slight.
> Presumably, the help file wording goes back to S-PLUS
> which (to my recollection) didn't allow zero-extent
> matrices. The actual behaviour is a clear improvement.
> - Peter D.
confirmed:
- S-PLUS aka S+ aka ... did not have 0-extent matrices nor arrays
- R having them makes for much more consistent code in several places.
- one could argue that matrix( , 3, 0) *is* a special case of
an empty vector
Further confirmation [not for Peter, for other readers] :
> str(Null(diag(3)))
num[1:3, 0 ]
> identical(Null(diag(3)), matrix(pi, 3,0))
[1] TRUE
>
> On 10 Nov 2014, at 13:49 , Georgi Boshnakov <georgi.boshnakov at manchester.ac.uk> wrote:
>> Hi,
>>
>> Function Null from package MASS seems to return a matrix with zero columns and the expected number of rows when
>> the null space of the argument contains only the zero vector, e.g.
>>
>>> library(MASS)
>>> diag(nrow=3)
>> [,1] [,2] [,3]
>> [1,] 1 0 0
>> [2,] 0 1 0
>> [3,] 0 0 1
>>
>>> Null(diag(nrow=3))
>>
>> [1,]
>> [2,]
>> [3,]
>>
>> But the documentation of Null seems to imply that the result is numeric(0):
>>
>> -----------------------------------------------
>>
>> Value:
>>
>> The matrix 'N' with the basis for the null space, or an empty
>> vector if the matrix 'M' is square and of maximal rank.
>>
>> -----------------------------------------------
>>
>> (R version 3.1.1 Patched (2014-09-21 r66653) -- "Sock it to Me")
>>
>> Georgi
>>
>> ______________________________________________
>> R-devel at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
> --
> Peter Dalgaard, Professor,
> Center for Statistics, Copenhagen Business School
> Solbjerg Plads 3, 2000 Frederiksberg, Denmark
> Phone: (+45)38153501
> Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
More information about the R-devel
mailing list