Learn R Programming

gsubfn (version 0.1-3)

cati: cat with string interpolation

Description

Similar to "cat" except that the strings can include "gsubfn"-like string interpolation.

Usage

cati(..., file = "", sep = " ", fill = FALSE, labels = NULL, append = FALSE, env = parent.frame(), pattern = "[$]([[:alpha:]][[:alnum:].]*)|`([^`]+)`", backref = nchar(base::gsub("[^(]", "", pattern)), end = "")

Arguments

...
R objects which are coerced to character strings, concatenated, and printed, with the remaining arguments controlling the output.
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'".
sep
character string to insert between the objects to print.
fill
a logical or 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
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
env
Same as in "gsubfn". Normally not used.
pattern
Same as in "gsubfn". Normally not used.
backref
Same as in "gsubfn". Normally not used.
end
String to be appended to the output string. "sep" is not used to separate "end".

Value

  • None (invisible 'NULL').

Details

Similar to "cat" except that "gsub"-style string interpolcation can be used in the arguments.

See Also

Also see gsubfn.

Examples

Run this code
cati("pi = $pi, pi rounded = `round(pi,2)`\n")

# no comma after 3 as newline specified via end=
cati(1, 2, 3, sep = ",", end = "\n")

Run the code above in your browser using DataLab