[Rd] nrow(rbind(character(), character())) returns 2 (as documented but very unintuitive, IMHO)

Abby Spurdle @purd|e@@ @end|ng |rom gm@||@com
Fri May 17 07:09:09 CEST 2019

Herve Pages wrote:

> In my experience, and more generally speaking, the desire to treat
> 0-length vectors as a special case that deviates from the
> non-zero-length case has never been productive.

Good idea.

Gabriel Becker Wrote:

> > nrow(rbind(aa = c("a", "b", "c"), AA = character()))
> [1] 1

> By rights of the invariance that you and Hadley are advocating,  as far as
> I understand it, the last should give 2 rows, one of which is all NAs,
> rather than giving only one row as it currently does (and, I assume?,
> always has).

I think, ideally, this example should generate an error or a warning.

	[[alternative HTML version deleted]]

More information about the R-devel mailing list