compbiostats
compbiostats

Reputation: 993

array() in R is not giving correct dimensions

I have noticed that when I compute

x <- array(dim = c(10000, 10, 1))

R does not return an array with 10000 rows as it should. Instead, the command returns only 100 rows.

I have R version 3.4.3 "Kite-Eating-Tree".

Is there any reason why R truncates the number of array rows to 100?

Maybe this has to do with the R version I am currently using...

Any idea what may be going on here?

Any enlightenment is appreciated.

Upvotes: 0

Views: 62

Answers (1)

Roman Luštrik
Roman Luštrik

Reputation: 70653

This is expected behavior. Printing is limited to a certain number. By default, you probably have

> options("max.print")
$max.print
[1] 1000

and 100 rows * 10 columns is 1000. So by that logic, if you limited printing to 20, you would get two rows. Proof:

> options(max.print = 20)
> x
, , 1

         [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
    [1,]   NA   NA   NA   NA   NA   NA   NA   NA   NA    NA
    [2,]   NA   NA   NA   NA   NA   NA   NA   NA   NA    NA

options(max.print = 1000) # revert back to default

Upvotes: 2

Related Questions