format: Format a string with arguments

Description Usage Arguments Value Examples

View source: R/utils.R

Description

Substitutes the arguments into the argument str. See the examples below.

Usage

1
format(str, ..., context = "normal")

Arguments

str

the format string

...

the arguments to substitute into the string

context

'normal' or 'R'

Value

the resultant string

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
jmvcore::format('the {} was delish', 'fish')

# 'the fish was delish'

jmvcore::format('the {} was more delish than the {}', 'fish', 'cow')

# 'the fish was more delish than the cow'

jmvcore::format('the {1} was more delish than the {0}', 'fish', 'cow')

# 'the cow was more delish than the fish'

jmvcore::format('the {what} and the {which}', which='fish', what='cow')

# 'the cow and the fish'

jmvcore::format('that is simply not {}', TRUE)

# 'that is simply not true'

jmvcore::format('that is simply not {}', TRUE, context='R')

# 'that is simply not TRUE'

jmvcore documentation built on Feb. 6, 2020, 5:07 p.m.