These methods of base::format()
and base::print()
render a
(usually more) tidy readout of a tbl_ord that is consistent across all
original ordination classes.
Usage
# S3 method for class 'tbl_ord'
format(
x,
width = NULL,
...,
n = NULL,
max_extra_cols = NULL,
max_footer_lines = NULL
)
# S3 method for class 'tbl_ord'
print(
x,
width = NULL,
...,
n = NULL,
max_extra_cols = NULL,
max_footer_lines = NULL
)
Arguments
- x
A tbl_ord.
- width
Width of text output to generate. This defaults to
NULL
, which means use thewidth
option.- ...
Additional arguments.
- n
Number(s) of rows to show from each matrix factor, handled as by
tibble::format.tbl()
. If length 1, will apply to both matrix factors. To passNULL
to only one factor, be sure to pass as a list, e.g.n = list(6, NULL)
.- max_extra_cols
Number of extra columns to print abbreviated information for, if the width is too small for the entire tibble. If
NULL
, themax_extra_cols
option is used. The previously definedn_extra
argument is soft-deprecated.Maximum number of footer lines. If
NULL
, themax_footer_lines
option is used.
Value
The format()
method returns a vector of strings that are more
elegantly printed by the print()
method, which itself returns the tbl_ord
invisibly.
Details
The format
and print
methods for class 'tbl_ord' are adapted from those
for class 'tbl_df' and for class 'tbl_graph' from the
tidygraph package.
Note: The format()
function is tedius but cannot be easily modularized
without invoking recoverers, annotation, and augmentation multiple
times, thereby significantly reducing performance.
Examples
iris_pca <- ordinate(iris[1:4], prcomp)
# single value applies to both factors
print(iris_pca, n = 10)
#> # A tbl_ord of class 'prcomp': (150 x 4) x (4 x 4)'
#> # 4 coordinates: PC1, PC2, ..., PC4
#> #
#> # Rows (principal): [ 150 x 4 | 0 ]
#> PC1 PC2 PC3 ... |
#> |
#> 1 -2.68 -0.319 0.0279 |
#> 2 -2.71 0.177 0.210 |
#> 3 -2.89 0.145 -0.0179 |
#> 4 -2.75 0.318 -0.0316 |
#> 5 -2.73 -0.327 -0.0901 ... |
#> 6 -2.28 -0.741 -0.169 |
#> 7 -2.82 0.0895 -0.258 |
#> 8 -2.63 -0.163 0.0219 |
#> 9 -2.89 0.578 -0.0208 |
#> 10 -2.67 0.114 0.198 |
#> # ℹ 140 more rows |
#>
#> #
#> # Columns (standard): [ 4 x 4 | 2 ]
#> PC1 PC2 PC3 ... | name center
#> | <chr> <dbl>
#> 1 0.361 -0.657 0.582 | 1 Sepal.Length 5.84
#> 2 -0.0845 -0.730 -0.598 ... | 2 Sepal.Width 3.06
#> 3 0.857 0.173 -0.0762 | 3 Petal.Length 3.76
#> 4 0.358 0.0755 -0.546 | 4 Petal.Width 1.20
# double values apply to factors in order
print(iris_pca, n = c(6, 2))
#> # A tbl_ord of class 'prcomp': (150 x 4) x (4 x 4)'
#> # 4 coordinates: PC1, PC2, ..., PC4
#> #
#> # Rows (principal): [ 150 x 4 | 0 ]
#> PC1 PC2 PC3 ... |
#> |
#> 1 -2.68 -0.319 0.0279 |
#> 2 -2.71 0.177 0.210 |
#> 3 -2.89 0.145 -0.0179 ... |
#> 4 -2.75 0.318 -0.0316 |
#> 5 -2.73 -0.327 -0.0901 |
#> 6 -2.28 -0.741 -0.169 |
#> # ℹ 144 more rows |
#>
#> #
#> # Columns (standard): [ 4 x 4 | 2 ]
#> PC1 PC2 PC3 ... | name center
#> | <chr> <dbl>
#> 1 0.361 -0.657 0.582 ... | 1 Sepal.Length 5.84
#> 2 -0.0845 -0.730 -0.598 | 2 Sepal.Width 3.06
#> # ℹ 2 more rows | # ℹ 2 more rows
#>
# use `list()` to pass `NULL` (for default) to only one factor
print(iris_pca, n = list(2, NULL))
#> # A tbl_ord of class 'prcomp': (150 x 4) x (4 x 4)'
#> # 4 coordinates: PC1, PC2, ..., PC4
#> #
#> # Rows (principal): [ 150 x 4 | 0 ]
#> PC1 PC2 PC3 ... |
#> |
#> 1 -2.68 -0.319 0.0279 ... |
#> 2 -2.71 0.177 0.210 |
#> # ℹ 148 more rows |
#>
#> #
#> # Columns (standard): [ 4 x 4 | 2 ]
#> PC1 PC2 PC3 ... | name center
#> | <chr> <dbl>
#> 1 0.361 -0.657 0.582 | 1 Sepal.Length 5.84
#> 2 -0.0845 -0.730 -0.598 ... | 2 Sepal.Width 3.06
#> 3 0.857 0.173 -0.0762 | 3 Petal.Length 3.76
#> 4 0.358 0.0755 -0.546 | 4 Petal.Width 1.20
print(iris_pca, n = list(NULL, 2))
#> # A tbl_ord of class 'prcomp': (150 x 4) x (4 x 4)'
#> # 4 coordinates: PC1, PC2, ..., PC4
#> #
#> # Rows (principal): [ 150 x 4 | 0 ]
#> PC1 PC2 PC3 ... |
#> |
#> 1 -2.68 -0.319 0.0279 |
#> 2 -2.71 0.177 0.210 |
#> 3 -2.89 0.145 -0.0179 ... |
#> 4 -2.75 0.318 -0.0316 |
#> 5 -2.73 -0.327 -0.0901 |
#> # ℹ 145 more rows |
#>
#> #
#> # Columns (standard): [ 4 x 4 | 2 ]
#> PC1 PC2 PC3 ... | name center
#> | <chr> <dbl>
#> 1 0.361 -0.657 0.582 ... | 1 Sepal.Length 5.84
#> 2 -0.0845 -0.730 -0.598 | 2 Sepal.Width 3.06
#> # ℹ 2 more rows | # ℹ 2 more rows
#>