read_sub: Subset lines and read into a 'tibble'

View source: R/read.R

read_subR Documentation

Subset lines and read into a tibble

Description

Read in the lines in .file, (optionally) identify the first line to match .pattern and starting here read into a tibble with .delim as separator and clean names via clean_names. All lines are read in if no .pattern is passed (the default).

Usage

read_sub(.file, .pattern = NULL, .delim = ",", ...)

Arguments

.file

A path to a file or a connection.

.pattern

Pattern to look for.

.delim

Single character used to separate fields within a record.

...

Further arguments passed to read_delim.

Value

A tibble.

Examples

lines <- c(
  "key_1,val_1",
  "key_2,val_2",
  "",
  "y,x_1,x_2",
  "1,low,0.989",
  "0,medium,-1.923"
)
temp_file <- tempfile()
writeLines(lines, temp_file)
read_sub(temp_file, "(?=.*y)(?=.*x_1)(?=.*x_2)")


albutz/tidyhelpr documentation built on May 9, 2022, 12:03 a.m.