Warning in R: reached getOption(“max.print”) | How to Increase Limit
This page explains how to handle the warning message “reached getOption(“max.print”) — omitted X entries” in the R programming language.
The article will consist of these content blocks:
Let’s dive right into the examples…
Example 1: Reproduce Notification: reached getOption(“max.print”)
Example 1 illustrates how to replicate the notification “[ reached getOption(“max.print”) — omitted X entries ]” in the RStudio console.
Let’s assume that we have a very long vector in R and we want to print this vector to the RStudio console:
x <- 1:10000 # Create long vector x # Print vector # ... 993 994 995 996 997 998 999 1000 # [ reached getOption("max.print") -- omitted 9000 entries ]
The warning message “[ reached getOption(“max.print”) — omitted 9000 entries ]” occurred after running the previous R code.
The reason for this is that by default the global options of R cut off outputs after the 1000th entry.
So how can we change this? This is what I’ll explain next!
Example 2: Increasing Limit of max.print
Example 2 illustrates how to increase the limit of max.print by changing the global options in R. Have a look at the following R code:
options(max.print = 10000) # Change global options
Now, let’s print our vector object x once more to the RStudio console:
x # Print vector # ... 9993 9994 9995 9996 9997 9998 9999 10000
The entire vector object is printed to the RStudio console. Looks great!
Note that the global options are now changed for the whole R session. In case you want to reset these options, you either have to decrease the max.print limit by specifying the default value in the options function or you have to restart R.
Video & Further Resources
Would you like to learn more about max.print in R? Then you may want to have a look at the following video of my YouTube channel. In the video, I show the topics of this article:
The YouTube video will be added soon.
Furthermore, I can recommend to have a look at the related articles that I have published on this website:
In summary: In this tutorial you learned how to set the global options to increase the max.print limit in the R programming language. If you have any additional questions, let me know in the comments below.
13 Comments. Leave new
Hello!
I appreciate the tips. My data limit is about 15268500, I used your code in order to increase the limit “I replaced the 10000 in your code with 15268500”. after running the code the imported data was only 3817125 and the same error appeared? Any suggestion to import the whole data?
Regards
Hey Abdelrhim,
This is a huge number, and I don’t know if there is a limit that cannot be exceeded no matter what. Is there maybe a way to split your data into chunks before printing it?
Regards,
Joachim
# Check
# Source: https://community.snowflake.com/s/article/Read-data-in-chunks-from-Snowflake-using-R
# Limit of max.print = MAX_INT = 2^31 – 1
# MAX_INT – https://en.wikipedia.org/wiki/2,147,483,647#In_computing
p <- 1:2147483647
options(max.print = 2147483647)
# The following print takes some time 🙂
p
Thanks for sharing!
Started running this about 1 hour ago (RStudio on Win10, 8 GB RAM, Intel i7 CPU):
still printing… exceeding 182 000 000
J.M. Lietaer
Belgium, EU
Hmm, sounds like a very long execution time. Is there a specific reason why you have to do this? 🙂
Greetings from Germany to Belgium!
Hi, Joachim.
The only reason is: curiosity. Is the maximum max.print value really MAX_INT (based on the information mentioned before) ?
Will it run until the end or not ?
Maybe an error, a memory issue, … ?
At this time R Session consumes only2.6 MB and R object consume MB or memory (last value of p is about 760 000 000).
Correction:
At this time R Session consumes only 2.6 MB and R objects consumes only 42 MB of memory (last value of p was about 760 000 000).
Sounds interesting. Please let me know if it worked and how long it took 🙂
As promised, this is the result:
p continues to be printed until MAX_INT (2147483647) is reached
…cut…
[2147483638] 2147483638 2147483639 2147483640 2147483641 2147483642 2147483643 2147483644 2147483645 2147483646
[2147483647] 2147483647
Adding 1 to p gives an error, as expected:
> p+1
Error: cannot allocate vector of size 16.0 Gb
Total time of the print sequence 1:2147483647 is 6h37′ (about 325.000.000 prints / h)
Hardware is, as mentioned before:
RStudio 2021.09.0 Build 351 on Win10, 8 GB RAM, Intel i7 CPU
Greetings from Belgium,
J.M.
This is very interesting J.M., thanks a lot for sharing your results!
FYI
Source 1:
https://stat.ethz.ch/R-manual/R-devel/library/base/html/options.html
max.print:
integer, defaulting to 99999.
Source 2:
https://stat.ethz.ch/R-manual/R-devel/library/base/html/integer.html
Note that current implementations of R use 32-bit integers for integer vectors, so the range of representable integers is restricted to about 2 × 10^9
Thanks for sharing again 🙂