writeText: Write Text Lines to a File

View source: R/io.R

writeTextR Documentation

Write Text Lines to a File

Description

Write text to a file using writeLines and output a debug message by default

Usage

writeText(x, file, type = "", dbg = TRUE, ...)

Arguments

x

vector of character representing the lines to be written to file, passed to writeLines

file

path to file to be written, passed to writeLines

type

character string to be included in the debug message: "Writing <type>'file-path' ..."

dbg

if TRUE, debug messages are shown

...

further arguments passed to writeLines

Value

This function invisibly returns the path to the output file.

Examples

# 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"))

# Make the debug message more informative
writeText(x, file, type = "welcome file")

# Read lines back and show on the console
catLines(readLines(file))


KWB-R/kwb.utils documentation built on April 1, 2024, 7:12 a.m.