Skip to content
Prev 202181 / 398503 Next

bug or bizarre feature?

On Nov 30, 2009, at 2:24 PM, Henrique Dallazuanna wrote:

            
Less true than you might expect:

 > x <- 3.5
 > y <- 5.2
 > z <- array(0, dim=c(x,y))
 > z
      [,1] [,2] [,3] [,4] [,5]
[1,]    0    0    0    0    0
[2,]    0    0    0    0    0
[3,]    0    0    0    0    0

What happens is coercion toward zero of the argument, ... which may  
not be the same as the displayed value.

 > array
function (data = NA, dim = length(data), dimnames = NULL)
{
     data <- as.vector(data)
     dim <- as.integer(dim)
<snipped>

I was left wondering if as.integer(round(dim))) wouldn't be more what  
people would expect.