Try pmap and related functions in purrr: pmap(as.data.frame(m), ~ { cat("Called...\n"); print(c(...)) }) ## list()
On Mon, Jul 30, 2018 at 12:33 AM, David Hugh-Jones <davidhughjo...@gmail.com> wrote: > 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]] > > ______________________________________________ > R-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel -- Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel