write_lines_to_file: Write Lines to File

Description Usage Arguments Value Examples

View source: R/write_lines_to_file.R

Description

Write Lines to File

Usage

1
2
write_lines_to_file(lines, filepath = "", prepend = FALSE,
  print_file = TRUE)

Arguments

lines

character lines that will be written to file.

filepath

character filepath of file to write lines to.

prepend

logical should the new lines be prepended to the existing text? Defaults to FALSE, which implies that the new lines will be appended.

print_file

logical should the contents of the file be printed after editing? Defaults to TRUE.

Value

invisible return. Lines will be written to file as side effects to function call.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# create empty file.
fp <- file.path(tempdir(), "dummy")
file.create(fp)

# append lines to Dockerfile.
write_lines_to_file(c("# dummy line 1", "# dummy line 2"), 
filepath = fp)

# prepend lines to Dockerfile.
write_lines_to_file(c("# dummy line 3", "# dummy line 4"), 
filepath = fp, prepend = TRUE)

dockr documentation built on Dec. 20, 2019, 5:06 p.m.