f_list: Format List Series

Description Usage Arguments Value Examples

View source: R/f_list.R

Description

f_list - Format a vector of elements as a list series (e.g., c('A', 'B', 'C') becomes "A, B, and C").

f_list_amp - A ampersand wrapper for f_list with and = '&' set by default.

Usage

1
2
3
4
5
f_list(x, and = "and", oxford = TRUE, ...)

f_list_amp(x, and = "&", oxford = TRUE, ...)

ff_list(...)

Arguments

x

A vector of values to turn into a collapsed series.

and

The value to use for the 'and'. Commonly 'and' and '&' are used.

oxford

logical. If TRUE an oxford comma is used. If you use FALSE you are a monster.

...

ignored.

Value

Returns a string that is a list series.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
f_list(1)
f_list(1:2)
f_list(1:3)
f_list(1:5)

x <- c("parents", "Lady Gaga",  "Humpty Dumpty")
## Three things you love
sprintf('I love my %s.', f_list(x))
## Your parents are lady Gaga & Humpty Dumpty?????
sprintf('I love my %s.', f_list(x, oxford = FALSE))

sprintf('I love my %s.', f_list(x, and = '&'))
sprintf('I love my %s.', f_list_amp(x))

numform documentation built on Oct. 10, 2021, 1:10 a.m.