peek: Peek into a text file

View source: R/core.R

peekR Documentation

Peek into a text file

Description

This function looks at the first elements of a file, format it into a data frame and displays it. It can also just show the first lines of the file without formatting into a DF.

Usage

peek(path, onlyLines = FALSE, n, view = TRUE)

Arguments

path

Path linking to the text file.

onlyLines

Default is FALSE. If TRUE, then the first n lines are directly displayed without formatting.

n

Integer. The number of lines to extract from the file. Default is 100 or 5 if onlyLine = TRUE.

view

Logical, default it TRUE: whether the data should be displayed on the viewer. Only when onlyLines = FALSE.

Value

Returns the data invisibly.

Author(s)

Laurent Berge

See Also

See peek to have a convenient look at the first lines of a text file. See guess_delim to guess the delimiter of a text data set. See guess_col_types to guess the column types of a text data set.

See hdd, sub-.hdd and cash-.hdd for the extraction and manipulation of out of memory data. For importation of HDD data sets from text files: see txt2hdd.

Examples


# Example with the iris data set
iris_path = tempfile()
fwrite(iris, iris_path)

# The first lines of the text file on viewer
peek(iris_path)

# displaying the first lines:
peek(iris_path, onlyLines = TRUE)

# only getting the data from the first observations
base = peek(iris_path, view = FALSE)
head(base)


hdd documentation built on Aug. 25, 2023, 5:19 p.m.