Learn R Programming

readr (version 0.2.2)

read_file: Read a file into a string.

Description

Read a file into a string.

Usage

read_file(file, locale = default_locale())

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 http://, https://, ftp://, or ftps:// will be automatically downloaded. Remote gz files can also be automatically downloaded & decompressed.

Literal data is most useful for examples and tests. It must contain at least one new line to be recognised as data (instead of a path).

locale
The locale controls defaults that vary from place to place. The default locale is US-centric (like R), but you can use locale to create your own locale that controls things like the default time zone, encoding, decimal mark, big mark, and day/month names.

Examples

Run this code
read_file(file.path(R.home(), "COPYING"))

Run the code above in your browser using DataLab