This function allow user to define how data.table is printed.
print_options(
topn = 5,
nrows = 100,
class = TRUE,
row.names = TRUE,
col.names = "auto",
print.keys = TRUE,
trunc.cols = FALSE
)
The number of rows to be printed from the beginning and
end of tables with more than nrow
rows.
The number of rows which will be printed before truncation is enforced.
If TRUE
, the resulting output will include above each column its storage class (or a self-evident abbreviation thereof).
If TRUE
, row indices will be printed.
One of three flavours for controlling the display of column names in output. "auto"
includes column names above the data, as well as below the table if nrow(x) > 20
. "top"
excludes this lower register when applicable, and "none"
suppresses column names altogether (as well as column classes if class = TRUE
.
If TRUE
, any key
currently assigned to x
will be printed prior to the preview of the data.
If TRUE
, only the columns that can be printed in the console without wrapping the columns to new lines will be printed (similar to tibbles
).
None. This function is used for its side effect of changing options.
Notice that tidyfst has a slightly different printing default for data.table, which is it always prints the keys and variable class (not like data.table).
iris %>% as.data.table()
#> Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#> <num> <num> <num> <num> <fctr>
#> 1: 5.1 3.5 1.4 0.2 setosa
#> 2: 4.9 3.0 1.4 0.2 setosa
#> 3: 4.7 3.2 1.3 0.2 setosa
#> 4: 4.6 3.1 1.5 0.2 setosa
#> 5: 5.0 3.6 1.4 0.2 setosa
#> ---
#> 146: 6.7 3.0 5.2 2.3 virginica
#> 147: 6.3 2.5 5.0 1.9 virginica
#> 148: 6.5 3.0 5.2 2.0 virginica
#> 149: 6.2 3.4 5.4 2.3 virginica
#> 150: 5.9 3.0 5.1 1.8 virginica
print_options(topn = 3,trunc.cols = TRUE)
iris %>% as.data.table()
#> Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#> <num> <num> <num> <num> <fctr>
#> 1: 5.1 3.5 1.4 0.2 setosa
#> 2: 4.9 3.0 1.4 0.2 setosa
#> 3: 4.7 3.2 1.3 0.2 setosa
#> ---
#> 148: 6.5 3.0 5.2 2.0 virginica
#> 149: 6.2 3.4 5.4 2.3 virginica
#> 150: 5.9 3.0 5.1 1.8 virginica
# set all settings to default in tidyfst
print_options()
iris %>% as.data.table()
#> Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#> <num> <num> <num> <num> <fctr>
#> 1: 5.1 3.5 1.4 0.2 setosa
#> 2: 4.9 3.0 1.4 0.2 setosa
#> 3: 4.7 3.2 1.3 0.2 setosa
#> 4: 4.6 3.1 1.5 0.2 setosa
#> 5: 5.0 3.6 1.4 0.2 setosa
#> ---
#> 146: 6.7 3.0 5.2 2.3 virginica
#> 147: 6.3 2.5 5.0 1.9 virginica
#> 148: 6.5 3.0 5.2 2.0 virginica
#> 149: 6.2 3.4 5.4 2.3 virginica
#> 150: 5.9 3.0 5.1 1.8 virginica