Learn R Programming

readr (version 0.1.1)

read_lines: Read lines from a file or string.

Description

Read lines from a file or string.

Usage

read_lines(file, n_max = -1L)

Arguments

file
Either a path to a file, a connection, or literal data (either a single string or a raw vector).

Files ending in .gz, .bz2, .xz, or .zip will be automatically uncompressed. Files starting with

n_max
Number of lines to read. If n is -1, all lines in file will be read. For large files, this may

Value

  • A character vector with one element for each line.

Examples

Run this code
read_lines(system.file("extdata/mtcars.csv", package = "readr"))
read_lines("1\n\n2")
read_lines("\n")

Run the code above in your browser using DataLab