title: Suppress large output to R console
body: <p>How can I make R check whether an object is too large to print in the console? "Too large" here means larger than a user-defined value.</p>
  
  <p>Example: You have a list <code>f_data</code> with two elements <code>f_data$data</code> (a 100MB data.frame) and <code>f_data$info</code> (for instance, a vector). Assume you want to inspect the first few entries of the <code>f_data$data</code> data.frame but you make a mistake and type <code>head(f_data)</code> instead of <code>head(f_data$data)</code>. R will try to print the whole content of <code>f_data</code> to the console (which would take forever).
  Is there somewhere an option that I can set in order to suppress the output of objects that are larger than let's say 1MB?</p>
  
  <p>Edit: Thank you guys for your help. After implementing the <code>max.rows</code> option I realized that this gives indeed the desired output. BUT the problem that the output takes very long to show up still persists. I will give you a proper example below.</p>
  
  <pre><code>df_nrow=100000
  df_ncol=100
  #create list with first element being a large data.frame
  #second element is a short vector
  test_list=list(df=data.frame(matrix(rnorm(df_nrow*df_ncol),nrow=df_nrow,ncol=df_ncol)),
                 vec=1:110)
  
  #only print the first 100 elements of an object
  options(max.print=100)
  
  #head correctly displays the first row of the data.frame
  #BUT for some reason the output takes really long to show up in the console (~30sec)
  head(test_list)
  #let's try to see how long exactly
  system.time(head(test_list))
  #   user  system elapsed 
  #      0       0       0
  #well, obviously system.time is not the proper tool to measure this
  
  #the same problem if I just print the object to the console without using head
  test_list$df
  </code></pre>
  
  <p>I assume that R performs some sort of analysis on the object being printed and this is what takes so long.</p>
  
  <p>Edit 2:
  As per my comment below, I checked whether the problem persists if I use a <code>matrix</code> instead of a <code>data.frame</code>.</p>
  
  <pre><code>#create list with first element being a large MATRIX
  test_list=list(mat=matrix(rnorm(df_nrow*df_ncol),nrow=df_nrow,ncol=df_ncol),vec=1:110)
  
  #no problem
  head(test_list)
  
  #no problem
  test_list$mat
  </code></pre>
  
  <p>Could it be that the output to the console is not really efficiently implemented for <code>data.frame</code> objects?</p>