From ripley at stats.ox.ac.uk  Tue Jul 29 17:31:30 2003
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Tue Jul 29 17:31:17 2003
Subject: [Rd] cbind/rbind inconsistency with NULL parameter (PR#3585)
In-Reply-To: <200307291501.h6TF1kJH021916@pubhealth.ku.dk>
Message-ID: <Pine.LNX.4.44.0307291626460.12797-100000@gannet.stats>

That's as documented, on the help page.  (NULL is a zero-length argument.)
There's even a reason given.

Exactly which part of the help page did you not understand?

On Tue, 29 Jul 2003 jmartin2003@notamusica.com wrote:

> R-Version: 1.7.1  (2003-06-16)
> OS: Debian/GNU Linux
> 
> cbind and rbind handle NULL parameters inconsistently.
> 
> Consider:
>   > cbind()
>   NULL
>   > cbind(NULL)
>   NULL
> 
> And:
>   > cbind(diag(x = 1, 1, 1))
>        [,1]
>   [1,]    1
>   > cbind(NULL, diag(x = 1, 1, 1))
>        [,1]
>   [1,]    1
> 
> These seem to indicate that NULL parameters will be ignored in any call to
> cbind and rbind. However:
> 
> > cbind(NULL, diag(x = 1, 0, 1))
>      [,1] [,2]
> 
> I.e. if one dimension of another parameter to cbind/rbind is zero,
> cbind/rbind will create a row/column from the NULL parameter.
> 
> This inconsistency creates problems in the construction of matrices within
> loops and similar constructs.

So?  It's a documented feature.

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595


[Rd] cbind/rbind inconsistency with NULL parameter (PR#3585)
Prof Brian Ripley