Skip to content
Back to formatted view

Raw Message

Message-ID: <CAB8pepxNQxuqzuZUqTSqxcyD2kG9xmgyvv2ne72=o3OD2Wo=eQ@mail.gmail.com>
Date: 2019-05-17T05:09:09Z
From: Abby Spurdle
Subject: nrow(rbind(character(), character())) returns 2 (as documented but very unintuitive, IMHO)
In-Reply-To: <CAD4oTHFjq3YvMTFrvufAXMgFy6YOwrSoCya8y5NkjsoNm9n-wQ@mail.gmail.com>

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]]