co: Customizable Object Aware String

Description Usage Arguments sprintf-like types See Also Examples

Description

Produces a fully customizable object aware string with consecutive values separated by columns.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
## Default S3 method:
co(object, one = "%o has %n value%s: %c",
  some = one, none = gsub(": ", "", some), lots = some, nlots = 10,
  conjunction = NULL, bracket = "", ellipsis = nlots,
  oxford = FALSE, object_name = substitute(object), ...)

## S3 method for class 'character'
co(object, one = "%o has %n value%s: %c",
  some = one, none = gsub(": ", "", some), lots = some, nlots = 10,
  conjunction = NULL, bracket = "'", ellipsis = nlots,
  oxford = FALSE, object_name = substitute(object), ...)

## S3 method for class 'factor'
co(object, one = "%o has %n value%s: %c",
  some = one, none = gsub(": ", "", some), lots = some, nlots = 10,
  conjunction = NULL, bracket = "'", ellipsis = nlots,
  oxford = FALSE, object_name = substitute(object), ...)

## S3 method for class 'data.frame'
co(object, one = "%o has %n column%s\n%c",
  some = one, none = none, lots = some, nlots = 10,
  conjunction = NULL, ellipsis = nlots, oxford = FALSE,
  object_name = substitute(object), ...)

Arguments

object

The object of length n

one

The string to return if n = 1

some

The string to return if n is in 2, 3, ..., nlots - 1

none

The string to return if n = 0

lots

The string to return if n >= nlots

nlots

A count of the number of values to consider to be lots

conjunction

A string of the conjunction to separate the last value by or NULL.

bracket

A string to bracket the values by.

ellipsis

A count of the total number of values required to use an ellipsis.

oxford

A flag indicating whether to use the Oxford comma (if conjunction).

object_name

A string of the object name.

...

Unused.

sprintf-like types

The following sprintf-like types can be used in the custom messages:

c

the object as a comma separated list (produced by a cc function)

n

the length of the object

o

the name of the object

s

's' if n != 1 otherwise ”

r

'are' if n != 1 otherwise 'is'

See Also

cc

Examples

1
2
3
4
5
6
co(character())
x <- "fox"
co(x)
co(c(1,2,5))
co(1:10)
co(datasets::mtcars)

err documentation built on May 2, 2019, 3:07 p.m.

Related to co in err...