capture_print | R Documentation |
Returns what print(x)
would output on the console – if collapse
is set to anything other than NULL
, as a character scalar
(i.e. a string), otherwise as a character vector of output lines.
capture_print(x, collapse = NULL)
x |
R object of which the output of |
collapse |
Optional string for concatenating the results. If |
This is a simple convenience wrapper around utils::capture.output()
. Note that ANSI escape sequences
(e.g. as output by the print()
methods of tidyverse packages) are included in the result. To remove them, use cli::ansi_strip()
.
A character vector if collapse = NULL
, otherwise a character scalar.
mtcars |> pal::capture_print()
mtcars |> pal::capture_print(collapse = "\n") |> cat()
# to strip ANSI escape sequences, use `cli::ansi_strip()`
mtcars |> tibble::as_tibble()
mtcars |>
tibble::as_tibble() |>
pal::capture_print(collapse = "\n") |>
cli::ansi_strip() |>
cat()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.