Python-style Formatting of Strings.

Share:

Description

This function allows Python-style formatting of strings, whereby text of the form {0}, {1}, ..., {n} is substituted according to the matching argument passed to .... 0 corresponds to the first argument, 1 corresponds to the second, and so on.

Usage

1
pymat(x, ..., collapse = ", ")

Arguments

x

A string with arguments to be replaced in the form of {0}, {1}, ..., {n}.

...

Arguments to be substituted into x.

collapse

If vectors of length greater than 1 are passed to ..., then we collapse the vectors with this separator.

Examples

1
2
3
4
5
6
7
8
9
pymat(
  "My favourite fruits are: {0}, {1}, and {2}.",
  "apple", "banana", "orange"
)

pymat(
  "My favourite fruits are: {0}.",
  c("apple", "banana", "orange"), collapse=", "
)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.