One warning message you may encounter in R is:
[ reached getOption("max.print") -- omitted 502 rows ]
This message appears when you attempt to print more than 1000 values at once in RStudio.
By default, RStudio only lets you print 1000 values at once. However, you can easily increase this limit by using one of the following methods:
Method 1: Increase Limit to Specific Value
#increase print limit to 2000 values
options(max.print=2000)
Method 2: Increase Limit to Max Amount Allowed by Machine
#increase print limit to max allowed by your machine
options(max.print = .Machine$integer.max)
The following example shows how to use these methods in practice.
Example: Increase Print Limit in R
Suppose we create a data frame in R with 1,002 rows and 2 columns:
#make this example reproducible
set.seed(0)
#create data frame
df frame(x=runif(1002),
y=runif(1002))
#view head of data frame
head(df)
x y
1 0.8966972 0.68486090
2 0.2655087 0.38328339
3 0.3721239 0.95498800
4 0.5728534 0.11835658
5 0.9082078 0.03910006
6 0.2016819 0.50450503
Then suppose we attempt to print the entire data frame in RStudio:
#attempt to print entire data frame
df
We’re only able to view the first 500 rows (i.e. the first 1,000 values) and we receive the warning that 502 rows were omitted.
However, if we use the max.print function then we can increase the print limit to 2,500 values:
#increase print limit to 2500 values
options(max.print=2500)
#attempt to print entire data frame again
df
This time we’re able to print all 1,002 rows in the data frame and we receive no warning message since we increased the print limit.
If we’d like to take it to the extreme and set the print limit to the max number of values allowed by our machine, we can use the following syntax:
#increase print limit to max allowed by your machine
options(max.print = .Machine$integer.max)
However, only use this option if you absolutely need to be able to view every line in your data frame because this can take a long time to run if the data that you’re working with is extremely large.
Additional Resources
The following tutorials explain how to troubleshoot other common errors in R:
How to Fix in R: names do not match previous names
How to Fix in R: longer object length is not a multiple of shorter object length
How to Fix in R: contrasts can be applied only to factors with 2 or more levels