R/qklook.R

Defines functions qklook

Documented in qklook

#' Glimpse into a table-like object
#' A simple function to make a "head" of the data on both rows and column, of custom length
#' @param x An object coercible to \code{matrix} format
#' @param nrows How many rows to print (default = 8)
#' @param ncols How many columns to print (default = 8)
#'
#' @return a printed subset of the data

#' @export
#'
#' @examples
#' data(iris)
#' qklook(iris)
#' qklook(iris, 5,5)

qklook <- function(x, nrows=8, ncols=8){
  x_formatted <- as(x, "matrix")

  if(nrow(x) < nrows){
    nrows <- nrow(x)
  }
  if(ncol(x) < ncols){
    ncols <- ncol(x)
  }

  return(x[1:nrows, 1:ncols])
}
g-antonello/gautils documentation built on May 3, 2024, 10:51 a.m.