paste_and_cat: New Paste and Cat Rules

paste_and_catR Documentation

New Paste and Cat Rules

Description

The available functions are:

paste_()is the same as paste0 but uses an underscore to separate

cat0() is analogous to paste0 but for cat

catN() is the same as cat0 but automatically inserts a new line after the cat

paste_series() paste a series of things with a conjunction

paste_oxford() shortcut for paste_series as oxford comma

Usage

paste_(..., collapse = NULL)

cat0(..., file = "", fill = FALSE, labels = NULL, append = FALSE)

catN(..., file = "", fill = FALSE, labels = NULL, append = FALSE)

paste_series(
  ...,
  sep = c(",", ";"),
  conjunction = c("and", "or", "&"),
  use_oxford_comma = TRUE
)

paste_oxford(...)

Arguments

...

one or more R objects, to be converted to character vectors.

collapse

an optional character string to separate the results. Not NA_character_.

file

character - A connection, or a character string naming the file to print to. If "" (the default), cat prints to the standard output connection, the console unless redirected by sink.

fill

a logical or (positive) numeric controlling how the output is broken into successive lines. see ?cat

labels

character vector of labels for the lines printed. Ignored if fill is FALSE.

append

logical. Only used if the argument file is the name of file (and not a connection or "|cmd"). If TRUE output will be appended to file; otherwise, it will overwrite the contents of file.

sep

a character vector of strings to append after each element

conjunction

indicates the ending conjunction. e.g. setting to "and" would make c("a", "b", "c") paste into "a, b, and c"

use_oxford_comma

logical - do you want to use an oxford comma at the end?

Author(s)

Steven Nydick, steven.nydick@kornferry.com

Examples


paste_series("a")
paste_series("a", "b")
paste_series("a", "b", "c")
# works if putting entries into c function
paste_series(c("a", "b", "c"), "d")
# can use oxford comma or not
paste_series("a", "b", "c",
             use_oxford_comma = TRUE)
paste_series("a", "b", "c",
             use_oxford_comma = FALSE)
# makes no difference if fewer than 3 items
paste_series("a", "b",
             use_oxford_comma = TRUE)

roperators documentation built on July 26, 2023, 5:27 p.m.