R/dim.R

Defines functions replyr_ncol replyr_dim

Documented in replyr_dim replyr_ncol

#' Compute number of columns of a data.frame (work around https://github.com/rstudio/sparklyr/issues/976 ).
#'
#'
#' @param x tbl or item that can be coerced into such.
#' @return number of columns
#'
#' @examples
#'
#' d <- data.frame(x=c(1,2))
#' replyr_ncol(d)
#'
#' @export
replyr_ncol <- function(x) {
  length(colnames(x))
}




#' Compute dimensions of a data.frame (work around https://github.com/rstudio/sparklyr/issues/976 ).
#'
#' @param x tbl or item that can be coerced into such.
#' @return dimensions (including rows)
#'
#' @examples
#'
#' d <- data.frame(x=c(1,2))
#' replyr_dim(d)
#'
#' @export
replyr_dim <- function(x) {
  nrows <- replyr_nrow(x)
  ncol <- replyr_ncol(x)
  c(nrows, ncol)
}

Try the replyr package in your browser

Any scripts or data that you put into this service are public.

replyr documentation built on Nov. 1, 2019, 7:49 p.m.