Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8720629
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:05:00+00:00 2026-06-13T07:05:00+00:00

I have a bunch of large dataframes, so every time I want to display

  • 0

I have a bunch of large dataframes, so every time I want to display them, I have to use head:

head( blahblah(somedata) )

Typing head all the time gets old after the first few hundred times, so I’d like an easy way to do this if possible. One of the cool things about R compared to java that things like this are often really easy, if you know the secret incantation.

I searched in options, and found max.print, which almost works, except there is now a time delay.

head( blahblah(somedata) )

…. is instantaneous (to within the limits of my perception)

options(max.print=100)
blahblah(somedata)

…. takes about 3 seconds, so longer than typing head

Is there some way of making head be applied automatically when printing large data structures?

An piece of code which reproduces this behavior:

long_dataset = data.frame(a = runif(10e5), 
                          b = runif(10e5), 
                          c = runif(10e5))
system.time(head(long_dataset))
options(max.print = 6)
system.time(print(long_dataset))
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T07:05:02+00:00Added an answer on June 13, 2026 at 7:05 am

    I’d go along with @thelatemail’s suggestion, i.e. redefine print.data.frame:

    print.data.frame <- function(df) {
       if (nrow(df) > 10) {
          base::print.data.frame(head(df, 5))
          cat("----\n")
          base::print.data.frame(tail(df, 5))
       } else {
          base::print.data.frame(df)
       }
    }
    
    data.frame(x=1:100, y=1:100)
    #   x y
    # 1 1 1
    # 2 2 2
    # 3 3 3
    # 4 4 4
    # 5 5 5
    # ----
    #       x   y
    # 96   96  96
    # 97   97  97
    # 98   98  98
    # 99   99  99
    # 100 100 100
    

    A more elaborate version could line everything up together and avoid the repeated header, but you get the idea.

    You could put such function in your .Rprofile or Rprofile.site files (see ?Startup) so it will be there every time you start an R session.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a bunch of large HTML files and I want to run a
Basically I have a bunch of large strings that I want to remove spaces/punctuation/numbers
I have a large application running on a bunch of machines. Once every 5
I have a bunch of large XML files (total size of all files is
I have a large string in a variable that includes a whole bunch of
I have a large web app, and I think there are a bunch of
In SQL Server 2005, I have a query that involves a bunch of large-ish
I have a rather large text file that has a bunch of missing newlines,
I have bunch of temporal data which I want to convert to RDF format.
Currently in a large c++ project we are working on we have a bunch

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.