R/file_rows.R

Defines functions file_rows

Documented in file_rows

#' count number of rows in a file without needing to read file into R
#' @param file file path to be read in
#' @details
#' uses wc -l system call to count rows
#' @name file_rows
#' @export
file_rows <- function(file) {
  # add check for unix vs windows
  if (file.exists(file)) {
    sysCmd <- paste("wc -l", file)
    rowCount <- system(sysCmd, intern = T)
    rowCount <- sub("^\\s", "", rowCount)
    as.numeric(strsplit(rowCount, "\\s")[[1]][1])
  }
}

Try the PKPDmisc package in your browser

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

PKPDmisc documentation built on April 14, 2020, 5:49 p.m.