print.data.table.Rd
print.data.table
extends the functionalities of print.data.frame
.
Key enhancements include automatic output compression of many observations and concise column-wise class
summary.
# S3 method for data.table print(x, topn=getOption("datatable.print.topn"), # default: 5 nrows=getOption("datatable.print.nrows"), # default: 100 class=getOption("datatable.print.class"), # default: FALSE row.names=getOption("datatable.print.rownames"), # default: TRUE col.names=getOption("datatable.print.colnames"), # default: "auto" print.keys=getOption("datatable.print.keys"), # default: FALSE quote=FALSE, timezone=FALSE, ...)
x | A |
---|---|
topn | The number of rows to be printed from the beginning and end of tables with more than |
nrows | The number of rows which will be printed before truncation is enforced. |
class | If |
row.names | If |
col.names | One of three flavours for controlling the display of column names in output. |
print.keys | If |
quote | If |
timezone | If |
... | Other arguments ultimately passed to |
By default, with an eye to the typically large number of observations in a codedata.table, only the beginning and end of the object are displayed (specifically, head(x, topn)
and tail(x, topn)
are displayed unless nrow(x) < nrows
, in which case all rows will print).
#> a #> 1: 1 #> 2: 2 #> 3: 3 #> 4: 4 #> --- #> 997: 997 #> 998: 998 #> 999: 999 #> 1000: 1000#`quote` can be used to identify whitespace DT <- data.table(blanks = c(" 12", " 34"), noblanks = c("12", "34")) print(DT, quote = TRUE)#> "blanks" "noblanks" #> 1: " 12" "12" #> 2: " 34" "34"#`class` provides handy column type summaries at a glance DT <- data.table(a = vector("integer", 3), b = vector("complex", 3), c = as.IDate(paste0("2016-02-0", 1:3))) print(DT, class = TRUE)#> a b c #> <int> <cplx> <IDat> #> 1: 0 0+0i 2016-02-01 #> 2: 0 0+0i 2016-02-02 #> 3: 0 0+0i 2016-02-03#> a #> 1 #> 2 #> 3#`print.keys` can alert which columns are currently keys DT <- data.table(a=1:3, b=4:6, c=7:9, key="b,a") setindexv(DT, c("a", "b")) setindexv(DT, "a") print(DT, print.keys=TRUE)#> Key: <b, a> #> Indices: <a__b>, <a> #> a b c #> 1: 1 4 7 #> 2: 2 5 8 #> 3: 3 6 9