From d@vidhughjone@ @ending from gm@il@com  Mon Jul 30 06:33:19 2018
From: d@vidhughjone@ @ending from gm@il@com (David Hugh-Jones)
Date: Mon, 30 Jul 2018 05:33:19 +0100
Subject: [Rd] apply with zero-row matrix
In-Reply-To: <CAARY7khVXzxutThhKcq+ZftTE8-66eH-B-82xs-8TFyTTmGrkw@mail.gmail.com>
References: <CAARY7khVXzxutThhKcq+ZftTE8-66eH-B-82xs-8TFyTTmGrkw@mail.gmail.com>
Message-ID: <CAARY7kjL=buR9GE9rP8Y64D_WTdrFunfTMUXD2mw8P4gMsNrTQ@mail.gmail.com>

Forgive me if this has been asked many times before, but I couldn't find
anything on the mailing lists.

I'd expect apply(m, 1, foo) not to call `foo` if m is a matrix with zero
rows.
In fact:

m <- matrix(NA, 0, 5)
apply(m, 1, function (x) {cat("Called...\n"); print(x)})
## Called...
## [1] FALSE FALSE FALSE FALSE FALSE

Similarly for apply(m, 2,...) if m has no columns.
Is there a reason for this? Could it be documented?

David
-- 
Sent from Gmail Mobile

	[[alternative HTML version deleted]]



[Rd] apply with zero-row matrix
David Hugh-Jones