From jtelleri@@rproject @ending from gm@il@com  Tue Jul 31 08:19:33 2018
From: jtelleri@@rproject @ending from gm@il@com (Juan Telleria Ruiz de Aguirre)
Date: Tue, 31 Jul 2018 08:19:33 +0200
Subject: [Rd] 
 Code Optimization: print.data.frame + as.data.frame(head(x,
 n = options("max.print")))
In-Reply-To: <CAJXDcw3T8MCv1MW7pAT8PHot2kYbwV1mch7-BpvViZ2UTPc_fg@mail.gmail.com>
References: <CAJXDcw3T8MCv1MW7pAT8PHot2kYbwV1mch7-BpvViZ2UTPc_fg@mail.gmail.com>
Message-ID: <CAJXDcw3J3-WZzTCvAcsDtvNKsGM3ain5WSn0r=HmuQ8Nzd_jWg@mail.gmail.com>

I polished a little bit more the function:

* Used:  getOption("max.print")
* Added comment at the end:  cat('[ reached getOption("max.print") --
omitted ', omitted,' rows ]')

function (x, ..., digits = NULL, quote = FALSE, right = TRUE,
          row.names = TRUE)
{
  n <- length(row.names(x))
  if (length(x) == 0L) {
    cat(sprintf(ngettext(n, "data frame with 0 columns and %d row",
                         "data frame with 0 columns and %d rows"), n), "\n",
        sep = "")
  }
  else if (n == 0L) {
    print.default(names(x), quote = FALSE)
    cat(gettext("<0 rows> (or 0-length row.names)\n"))
  }
  else {

    omitted <- nrow(x)-getOption("max.print")

    x <- as.data.frame(head(x, n = getOption("max.print")))

    m <- as.matrix(format.data.frame(x, digits = digits,
                                     na.encode = FALSE))
    if (!isTRUE(row.names))
      dimnames(m)[[1L]] <- if (isFALSE(row.names))
        rep.int("", n)
    else row.names
    print(m, ..., quote = quote, right = right)

    if((nrow(x)-getOption("max.print"))>0){

      cat('[ reached getOption("max.print") -- omitted ', omitted,' rows ]')

    }

  }
  invisible(x)
}

	[[alternative HTML version deleted]]



[Rd] Code Optimization: print.data.frame + as.data.frame(head(x, n = options("max.print")))
Juan Telleria Ruiz de Aguirre