Skip to contents

Prettier printing for matrices and data frames.

Usage

pprint(x, ...)

# S3 method for class 'matrix'
pprint(x, rowdots = NULL, coldots = NULL, digits = NULL, ...)

# S3 method for class 'data.frame'
pprint(x, rowdots = NULL, coldots = NULL, digits = NULL, ...)

Arguments

x

A matrix or data.frame.

...

Additional optional arguments. None are used at present.

rowdots

Integer specifying the row to replace with ... notation. Default is 4.

coldots

Integer specifying the column to replace with ... notation. Default is 4.

digits

The minimum number of significant digits to be printed in values.

Details

For a matrix or data.frame (which are coerced to a matrix via data.matrix, pprint() will replace all the rows starting from rowdots up to and including the second-to-last row with a single row filled with ...s. The same is applied to the columns as well. Hence a large matrix (or data.frame) will be printed in a much more compact form.

Examples

pprint(randn(100, 100))
#> 100 x 100 matrix of doubles: 
#> 
#>              [,1]       [,2]       [,3] ...     [,100]
#> [1,]   -0.2060872 -1.1380124 -1.1936412 ...  1.6600532
#> [2,]    0.0191776 -0.5580151 -0.7517233 ...  0.6097109
#> [3,]    0.0295608  1.0525385  1.4558414 ...  1.0163791
#> ...           ...        ...        ... ...        ...
#> [100,]  0.1221034 -0.5035929 -0.1454269 ... -0.9218250
pprint(resize(1:100, 10, 10))
#> 10 x 10 matrix of integers: 
#> 
#>       [,1] [,2] [,3] ... [,10]
#> [1,]     1   11   21 ...    91
#> [2,]     2   12   22 ...    92
#> [3,]     3   13   23 ...    93
#> ...    ...  ...  ... ...   ...
#> [10,]   10   20   30 ...   100