Escapes the POSIX-standard newline control character LF
(aka \n
) which is the standard on Unix/Linux and recent
versions of macOS. Set escape_cr = TRUE
in order to also escape the carriage return character CR
(aka \r
) commonly used on Microsoft Windows.
See also
Other string functions:
as_chr()
,
as_comment_str()
,
as_line_feed_chr()
,
as_str()
,
capitalize_first()
,
dsv_colnames()
,
enum_str()
,
fuse_regex()
,
prettify_nr()
,
prose_ls()
,
sentenceify()
,
wrap_chr()
Examples
library(magrittr)
# read in and print RStudio add-in registration file as-is
text <-
fs::path_package(package = "pal",
"rstudio", "addins.dcf") |>
readr::read_file() %T>%
pal::cat_lines()
#> Name: Build `README.Rmd`
#> Description: Executes `pal::build_readme()`.
#> Binding: build_readme
#> Interactive: false
#>
# escape newlines and print again
pal::escape_lf(text) |> pal::cat_lines()
#> Name: Build `README.Rmd`\nDescription: Executes `pal::build_readme()`.\nBinding: build_readme\nInteractive: false\n