Skip to content
Back to formatted view

Raw Message

Message-ID: <CAF8bMcZxbppcD8M2Eu4c0wBiNXH11z=Xjcto=kJRpATOtK5hYw@mail.gmail.com>
Date: 2015-12-17T22:40:18Z
From: William Dunlap
Subject: array() ignores illegal non-list dimnames

Is there a reason that array() silently ignores dimnames that are not
a list but matrix() gives an error?

  > str(matrix(11:14, 2, 2, dimnames=c("Rows","Cols")))
  Error in matrix(11:14, 2, 2, dimnames = c("Rows", "Cols")) :
    'dimnames' must be a list
  > str(array(11:14, dim=c(2, 2), dimnames=c("Rows","Cols")))
   int [1:2, 1:2] 11 12 13 14

I noticed this in lhs:::geneticLHS, which has the line
            J <- array(NA, dim = c(n, k, pop), dimnames = c("points",
"variables", "hypercubes"))
where the non-list dimnames has no effect, and no warning or error.

Bill Dunlap
TIBCO Software
wdunlap tibco.com