paste_and_cat: New Paste and Cat Rules

Description Usage Arguments Author(s) Examples

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
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

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. If it is "|cmd", the output is piped to the command given by ‘cmd’, by opening a pipe connection.

fill

a logical or (positive) numeric controlling how the output is broken into successive lines. If FALSE (default), only newlines created explicitly by "\n" are printed. Otherwise, the output is broken into lines with print width equal to the option width if fill is TRUE, or the value of fill if this is numeric. Linefeeds are only inserted between elements, strings wider than fill are not wrapped. Non-positive fill values are ignored, with a warning.

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 string to separate the terms. Not NA_character_.

conjunction

the conjunction to use to collapse the final elements in the series (such as and, or, &, or something else)

use_oxford_comma

whether to use the oxford comma in the series (standard in American English) or to not use the oxford comma

Author(s)

Steven Nydick, steven.nydick@kornferry.com

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
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 Feb. 10, 2022, 1:07 a.m.