cat_lines: Convert to character vector and print newline-separated

cat_linesR Documentation

Convert to character vector and print newline-separated

Description

Convenience wrapper around as_chr() and base::cat(), mainly intended for interactive use.

Usage

cat_lines(...)

Arguments

...

R object(s) to convert to character and print. Dynamic dots are supported.

Value

None (invisible NULL).

See Also

cli::cat_line() for a faster alternative that doesn't recursively convert its input to type character.

xfun::raw_string() (and xfun::file_string()) for an alternative approach to the same use case (but without any conversion to type character at all).

writeLines(con = stdout()) for a base R alternative that only accepts character inputs.

Examples

fs::path_package(package = "pal",
                 "rstudio", "addins.dcf") |>
  readr::read_lines() |>
  pal::cat_lines()

# conversion to type character, recursive vs. non-recursive
to_convert <- list(tibble::tibble(a = 1:3), "A", factor("wonderful"), xfun::strict_list("day"))

to_convert |> pal::cat_lines()
to_convert |> cli::cat_line()

# this OTOH only accepts chr inputs
try(
  to_convert |> writeLines()
)

salim-b/pal documentation built on Feb. 28, 2025, 6:51 p.m.