R/file.head.R

Defines functions file.head

Documented in file.head

file.head <- function(file, n = 6, truncate.cols = TRUE){
    lns <- readLines(file, n = n)
    lns <- gsub("\t", "\\\\t", lns)
    if(truncate.cols){
        try(file.head.lns <- substr(lns, 1, getOption("width") - 1), silent = TRUE)
        if(!exists("file.head.lns")){
            Encoding(lns) <- "bytes"
            file.head.lns <- substr(lns, 1, getOption("width") - 1)
        }
    }
    cat(file.head.lns, sep = "\n")
}

Try the descr package in your browser

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

descr documentation built on Nov. 28, 2023, 1:10 a.m.