[Rd] cbind/rbind inconsistency with NULL parameter (PR#3585)
Prof Brian Ripley
ripley at stats.ox.ac.uk
Tue Jul 29 17:31:30 MEST 2003
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 at 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 at 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
More information about the R-devel
mailing list