Learn R Programming

brio (version 1.1.3)

file_line_endings: Retrieve the type of line endings used by a file

Description

Retrieve the type of line endings used by a file

Usage

file_line_endings(path)

Value

The line endings used, one of

  • '\n' - if the file uses Unix line endings

  • '\r\n' - if the file uses Windows line endings

  • NA - if it cannot be determined

Arguments

path

A character string of the path to the file to read.

Examples

Run this code
tf1 <- tempfile()
tf2 <- tempfile()
write_lines("foo", tf1, eol = "\n")
write_lines("bar", tf2, eol = "\r\n")

file_line_endings(tf1)
file_line_endings(tf2)

unlink(c(tf1, tf2))

Run the code above in your browser using DataLab