Skip to content
Prev 57494 / 63421 Next

head.matrix can return 1000s of columns -- limit to n or add new argument?

Hi,

Alternatively, how about a new glance() generic that would do something 
like this:

 > library(DelayedArray)
 > glance <- DelayedArray:::show_compact_array

 > M <- matrix(rnorm(1e6), nrow = 1000L, ncol = 2000L)
 > glance(M)
<1000 x 2000> matrix object of type "double":
                [,1]        [,2]        [,3] ...    [,1999]    [,2000]
    [1,]  -0.8854896   1.8010288   1.3051341   . -0.4473593  0.4684985
    [2,]  -0.8563415  -0.7102768  -0.9309155   . -1.8743504  0.4300557
    [3,]   1.0558159  -0.5956583   1.2689806   .  2.7292249  0.2608300
    [4,]   0.7547356   0.1465714   0.1798959   . -0.1778017  1.3417423
    [5,]   0.8037360  -2.7081809   0.9766657   . -0.9902788  0.1741957
     ...           .           .           .   .          .          .
  [996,]  0.67220752  0.07804320 -0.38743454   .  0.4438639 -0.8130713
  [997,] -0.67349962 -1.15292067 -0.54505567   .  0.4630923 -1.6287694
  [998,]  0.03374595 -1.68061325 -0.88458368   . -0.2890962  0.2552267
  [999,]  0.47861492  1.25530912  0.19436708   . -0.5193121 -1.1695501
[1000,]  1.52819218  2.23253275 -1.22051720   . -1.0342430 -0.1703396

 > A <- array(rnorm(1e6), c(50, 20, 10, 100))
 > glance(A)
<50 x 20 x 10 x 100> array object of type "double":
,,1,1
             [,1]       [,2]       [,3] ...      [,19]      [,20]
  [1,] 0.78319619 0.82258390 0.09122269   .  1.7288189  0.7968574
  [2,] 2.80687459 0.63709640 0.80844430   . -0.3963161 -1.2768284
   ...          .          .          .   .          .          .
[49,] -1.0696320 -0.1698111  2.0082890   .  0.4488292  0.5215745
[50,] -0.7012526 -2.0818229  0.7750518   .  0.3189076  0.1437394

...

,,10,100
             [,1]       [,2]       [,3] ...      [,19]      [,20]
  [1,]  0.5360649  0.5491561 -0.4098350   .  0.7647435  0.5640699
  [2,]  0.7924093 -0.7395815 -1.3792913   .  0.1980287 -0.2897026
   ...          .          .          .   .          .          .
[49,]  0.6266209  0.3778512  1.4995778   . -0.3820651 -1.4241691
[50,]  1.9218715  3.5475949  0.5963763   .  0.4005210  0.4385623

H.
On 9/16/19 00:54, Michael Chirico wrote: