I am running Rstudio 0.99.489 and R-3.2.3 on Windows 7
How can I avoid printing V1 and N at the bottom of the data ?
options(datatable.print.nrows = Inf)
dt <- data.table(sample.int(2e3, 1e4, T))
print(dt[ , .(.N), V1])
...
1980: 419 1
1981: 898 2
1982: 1260 1
V1 N
You can manipulate print of an object as a regular character vector.
library(data.table)
options(datatable.print.nrows = Inf)
dt = data.table(sample.int(2e3, 1e4, T))
myprint = function(x){
prnt = capture.output(print(x))
cat(prnt[-length(prnt)], sep="\n")
}
myprint(dt[ , .(.N), V1])
Here's an alternative to consider. Since data.table
s are enhanced data.frame
s, why not just use the print
method for data.frame
s? That way, you get both printing all the rows of the inputs, but without the column names appearing at the bottom as well.
For instance, the following dataset is sufficient to demonstrate the behavior of printing names at the bottom.
set.seed(1)
dt <- data.table(sample(21, 1000, TRUE)) ## Sufficient to demonstrate behavior
dt[, .N, by = V1] ## Shows the names at the bottom
You can manually specify the print.data.frame
method, like this:
print.data.frame(dt[, .N, by = V1]) ## Specify use of data.frame print method
Or, since you're not printing something that affects your original data.table
, you could also do something like this:
setDF(dt[, .N, by = V1])[] ## dt stays a `data.table`
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With