Read the first n data rows of a delimited text file and return
the result as a base R data.frame (a kind of head() for files).
Usage
peekFile(file, n = 10, ..., output = c("data.frame", "tibble"))Arguments
- file
character string specifying the file name.
- n
integer specifying the number of data rows to read, defaults to 10.
- ...
additional arguments passed to
readr::read_delim(), e.g.delimorskip. The argumentsn_maxandshow_col_typesare managed internally and will be ignored if supplied;guess_maxdefaults tonbut may be overridden.- output
character, either
"data.frame"(default) or"tibble", determining the class of the returned object. Conversion todata.frameis done bytoBaseR(). The argument can be abbreviated. Note that it must be given as a named argument, as it follows the dots.
Details
This function is intended for quickly inspecting large text files,
including compressed files supported by readr::read_delim().
Column types are guessed from the previewed rows only (the default
guess_max equals n). If early rows are not representative,
supply a larger guess_max via the dots.
See also
readr::read_delim(), toBaseR(), head(),
Other file.io:
parseSASDatalines(),
pdfManual(),
readDownload()
