Learn R Programming

err (version 0.2.0)

co: Customizable Object Aware String

Description

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

Usage

# S3 method for default
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 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 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 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.

<code>sprintf</code>-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

Run this code
# NOT RUN {
co(character())
x <- "fox"
co(x)
co(c(1,2,5))
co(1:10)
co(datasets::mtcars)
# }

Run the code above in your browser using DataLab