A useful function for exploratory work or when coding. Takes a list as an argument and prints a glimpse of the data contained in each list element and the dimensions of each list element. If the list contains more than 5 list elements, only the first 5 elements are printed to console with no warning. The function will print a maximum of 10 values if the list element is a vector and 10 rows and 5 columns if the list element is a matrix.

inspect_list(x)

Arguments

x

A list of vectors or matrices

Details

NOTE: There are currently no checks built in to handle a list of lists. In this case, everything in the sublists will be printed with no checks or warnings.

Examples

x <- list(
  matrix(runif(100), nrow = 20, ncol = 5),
  matrix(runif(100), nrow = 10, ncol = 10)
)

inspect_list(x)
#> [[1]]
#> [[1]][[1]]
#>           [,1]      [,2]      [,3]     [,4]       [,5]
#>  [1,] 0.481114 0.4962330 0.0715536 0.839312 0.81831202
#>  [2,] 0.872365 0.8022006 0.3760615 0.179017 0.52836253
#>  [3,] 0.926663 0.8279745 0.0155903 0.936745 0.34410768
#>  [4,] 0.114322 0.6127928 0.4172785 0.415890 0.22768004
#>  [5,] 0.988184 0.0974007 0.5280884 0.359694 0.48987618
#>  [6,] 0.128472 0.4210186 0.1926128 0.832815 0.00165537
#>  [7,] 0.952287 0.0368911 0.1636980 0.744052 0.91803970
#>  [8,] 0.829245 0.8988369 0.2597029 0.312864 0.53216632
#>  [9,] 0.243960 0.9781346 0.5630506 0.938791 0.55779670
#> [10,] 0.859603 0.6247347 0.7268068 0.276075 0.46345850
#> 
#> [[1]][[2]]
#> [1] 20  5
#> 
#> 
#> [[2]]
#> [[2]][[1]]
#>              [,1]      [,2]      [,3]     [,4]      [,5]
#>  [1,] 0.445471254 0.4737315 0.2474426 0.377687 0.9927506
#>  [2,] 0.290370407 0.5437382 0.5200297 0.661250 0.8346029
#>  [3,] 0.543138769 0.7941916 0.4968624 0.189791 0.4800536
#>  [4,] 0.498325735 0.7595838 0.6729261 0.295115 0.2644405
#>  [5,] 0.722842331 0.1051609 0.9557506 0.424462 0.4197501
#>  [6,] 0.347577390 0.4201572 0.5678417 0.795067 0.4598746
#>  [7,] 0.106388609 0.0190479 0.9653376 0.152793 0.6957966
#>  [8,] 0.655070493 0.2351442 0.0221112 0.731753 0.3986051
#>  [9,] 0.552025458 0.6360015 0.5418912 0.121713 0.8195407
#> [10,] 0.000408617 0.1760657 0.7185175 0.887622 0.0503351
#> 
#> [[2]][[2]]
#> [1] 10 10
#> 
#>