On Wed, 30 Jul 2003, Tony Plate wrote: > The R help for cbind/rbind states: > > > For `cbind' (`rbind'), vectors of zero length are ignored unless > > the result would have zero rows (columns), for S compatibility. > > (Zero-extent matrices do not occur in S and are not ignored in R.) > > I presume this means the S language as defined in the Blue Book ("The ^New > S Language", Becker Chambers & Wilks, 1988), though in a brief reading I > couldn't find any mention of such a constraint in the sections on Matrices > and on Arrays (pages 126 thru 135 in my copy), or any mention of such > constraints or behavior in the descriptions of the functions cbind/rbind() > and matrix().
That's R code for `S-PLUS 3.4 compatibility', the system that used (at least) to be used when checking for compatibility. E.g. > cbind(a=1:3, b=integer(0), c=4:6) a c [1,] 1 4 [2,] 2 5 [3,] 3 6 > cbind(a=1:3, b=NULL, c=4:6) a c [1,] 1 4 [2,] 2 5 [3,] 3 6 under S-PLUS 3.4. This is explained (in some way) in the FAQ (Blue & White books). > FWIW, in S-plus 6.1 zero-extent matrices are allowed, and cbind/rbind do > not seem to behave in this way (under Windows at least). > > E.g.: > S6.1> matrix(nrow=0,ncol=0) > logical matrix: 0 rows, 0 columns. Fails in S-PLUS 3.4. > S6.1> cbind(NULL, matrix(nrow=0,ncol=0)) > NULL > S6.1> cbind(numeric(0), matrix(1, nrow=0,ncol=1)) > NULL > S6.1> > > Also, FWIW, I have argued to Insightful that cbind/rbind returning NULL > here is a undesirable (along with other examples of inconsistent behavior > with zero-extent matrices), and they have replied that they have logged > these as bugs to be fixed in a future release. No one is attempting compatibility with things introduced in S-PLUS after R. > -- Tony Plate > > At Tuesday 04:31 PM 7/29/2003 +0100, Prof Brian Ripley wrote: > >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 [EMAIL PROTECTED] 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, [EMAIL PROTECTED] > >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 > > > >______________________________________________ > >[EMAIL PROTECTED] mailing list > >https://www.stat.math.ethz.ch/mailman/listinfo/r-devel > > ______________________________________________ > [EMAIL PROTECTED] mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-devel > -- Brian D. Ripley, [EMAIL PROTECTED] 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 ______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-devel