When I display an object in R (in the standard command line interface), and the object is very long, R cuts it with the message
[ reached getOption("max.print") -- omitted 538 rows ]
but still manages to clutter my terminal.
For me, the desired behavior would be as follows: if number of lines of output exceeds N, the output is stored to a temporary text file and the text file displayed using less.
A solution prototype uses capture.output
:
data(iris3)
t <- tempfile()
capture.output(print(iris), file=t)
system(paste0("less ", t))
It does more or less what I want, but (i) shares the max.print with the terminal (not good!) and (ii) does not run automatically when the output is too large.
Is there any way to achieve this? At least solving the (i) above would be of great help (such that capture.output works without a limit or with a limit different from that in the terminal).