Write text to a file using writeLines
and output a debug
message by default
writeText(x, file, type = "", dbg = TRUE, ...)
x | vector of character representing the lines to be written to
|
---|---|
file | path to file to be written, passed to |
type | character string to be included in the debug message: "Writing <type>'file-path' ..." |
dbg | if |
… | further arguments passed to |
This function invisibly returns the path to the output file
.
# Define text to be written to file x <- c("Hello", "world") # Write text to a temporary file and catch the file path file <- writeText(x, tempfile(fileext = ".txt"))#> Writing '/tmp/RtmpMsuQJ9/file37688738ee08.txt' ... ok.# Make the debug message more informative writeText(x, file, type = "welcome file")#> Writing welcome file '/tmp/RtmpMsuQJ9/file37688738ee08.txt' ... ok.#> Hello #> world