read_file | R Documentation |
read_file()
reads a complete file into a single object: either a
character vector of length one, or a raw vector. write_file()
takes a
single string, or a raw vector, and writes it exactly as is. Raw vectors
are useful when dealing with binary data, or if you have text data with
unknown encoding.
read_file(file, locale = default_locale())
read_file_raw(file)
write_file(x, file, append = FALSE, path = deprecated())
file |
Either a path to a file, a connection, or literal data (either a single string or a raw vector). Files ending in Literal data is most useful for examples and tests. To be recognised as
literal data, the input must be either wrapped with Using a value of |
locale |
The locale controls defaults that vary from place to place.
The default locale is US-centric (like R), but you can use
|
x |
A single string, or a raw vector to write to disk. |
append |
If |
path |
read_file
: A length 1 character vector.
read_lines_raw
: A raw vector.
read_file(file.path(R.home("doc"), "AUTHORS"))
read_file_raw(file.path(R.home("doc"), "AUTHORS"))
tmp <- tempfile()
x <- format_csv(mtcars[1:6, ])
write_file(x, tmp)
identical(x, read_file(tmp))
read_lines(I(x))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.