format: Format a string with arguments

View source: R/utils.R

formatR Documentation

Format a string with arguments

Description

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

Usage

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


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'


jamovi/jmvcore documentation built on Jan. 11, 2024, 4:17 a.m.