peek.Rd
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.
peek(path, onlyLines = FALSE, n, view = TRUE)
Path linking to the text file.
Default is FALSE
. If TRUE
, then the first n
lines are directly displayed without formatting.
Integer. The number of lines to extract from the file. Default is 100 or 5 if onlyLine = TRUE
.
Logical, default it TRUE
: whether the data should be displayed on the viewer. Only when onlyLines = FALSE
.
Returns the data invisibly.
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
.
# 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)
#> Delimiter: CSV
# displaying the first lines:
peek(iris_path, onlyLines = TRUE)
#> [1] "Sepal.Length,Sepal.Width,Petal.Length,Petal.Width,Species"
#> [2] "5.1,3.5,1.4,0.2,setosa"
#> [3] "4.9,3,1.4,0.2,setosa"
#> [4] "4.7,3.2,1.3,0.2,setosa"
#> [5] "4.6,3.1,1.5,0.2,setosa"
# only getting the data from the first observations
base = peek(iris_path, view = FALSE)
#> Delimiter: CSV
head(base)
#> Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#> 1: 5.1 3.5 1.4 0.2 setosa
#> 2: 4.9 3.0 1.4 0.2 setosa
#> 3: 4.7 3.2 1.3 0.2 setosa
#> 4: 4.6 3.1 1.5 0.2 setosa
#> 5: 5.0 3.6 1.4 0.2 setosa
#> 6: 5.4 3.9 1.7 0.4 setosa