ox: Oxford-comma separated lsts

View source: R/ox.R

oxR Documentation

Oxford-comma separated lsts

Description

Create Oxford-comma separated lsts with a variety of templates (see details).

With the exception of n > length(uj::av(...)), these functions appropriately process lsts of length 1 and 2.

Usage

ox(..., conj = "and", pref = "", quote = 0)

oxford(..., conj = "and", pref = "", quote = 0)

oxford_comma(..., conj = "and", pref = "", quote = 0)

ox_n(..., conj = "and", comp = "", quote = 0, n = 1, first = TRUE)

ox_and(..., pref = "", quote = 0)

ox_or(..., pref = "", quote = 0)

ox_nor(..., pref = "neither", quote = 0)

ox_either(..., quote = 0)

ox_neither(..., quote = 0)

ox_all(..., conj = "and", quote = 0)

ox_any(..., conj = "or", quote = 0)

ox_none(..., conj = "or", quote = 0)

ox_some(..., conj = "and", quote = 0)

ox_exactly(..., conj = "or", n = 1, quote = 0)

ox_less(..., conj = "and", n = 2, quote = 0)

ox_more(..., conj = "and", n = 1, quote = 0)

ox_fewer(..., conj = "and", n = 2, quote = 0)

ox_greater(..., conj = "and", n = 2, quote = 0)

ox_at_least(..., conj = "and", n = 1, quote = 0)

ox_at_most(..., conj = "and", n = 1, quote = 0)

ox_no_greater(..., conj = "and", n = 1, quote = 0)

ox_no_fewer(..., conj = "and", n = 1, quote = 0)

ox_no_more(..., conj = "and", n = 1, quote = 0)

ox_no_less(..., conj = "and", n = 1, quote = 0)

ox_or_more(..., conj = "and", n = 1, quote = 0)

ox_or_greater(..., conj = "and", n = 1, quote = 0)

ox_or_less(..., conj = "and", n = 1, quote = 0)

ox_or_fewer(..., conj = "and", n = 1, quote = 0)

Arguments

...

Any number of arguments coerceable to mode character.

conj

A complete character scalar conjunction to use between the next to last and last elements of the lst. Typical values are and, or and nor.

pref

A complete character scalar prefix to prepend to the lst.

quote

0, 1, or 2 indicating whether to leave lst elements unquoted, single-quote the lst elements, or double-quote the lst elements.

comp

A complete character scalar used for comparing to n, such as 'at least' or 'or fewer'.

n

A complete positive whole-number scalar.

first

TRUE or FALSE used to determine whether comp is placed in front of n rather than after n.

Details

Each function in this family operates from a template as shown in the following tables where {conj} and {n} represent the values of arguments conj and n; {pref} and {comp} indicate the potentially-NULL values of arguments pref and comp; and ⁠[a]⁠, ⁠[b]⁠, and ⁠[z]⁠ represents elements of a lst.

Simple lsts

These functions do not incorporate a number into the Oxford-comma separated lst:

  ox '{pref} [a], [b], ..., {conj} [z]'
  oxford  
  oxford_comma    
   
  ox_or '{pref} [a], [b], ..., or [z]'
  ox_and '{pref} [a], [b], ..., and [z]'
  ox_any '{pref} any of [a], [b], ..., {conj} [z]'
  ox_all '{pref} all of [a], [b], ..., {conj} [z]'
  ox_none '{pref} none of [a], [b], ..., {conj} [z]'
  ox_some '{pref} some of [a], [b], ..., {conj} [z]'
  ox_either '{pref} either [a], [b], ..., or [z]'
  ox_neither   '{pref} neither [a], [b], ..., nor [z]'



Numeric-comparison lsts

These functions incorporate a number into the Oxford-comma separated lst:

  ox_n   '{n} of [a], [b], ..., {conj} [z]'
  ox_exactly 'exactly {n} of [a], [b], ..., {conj} [z]'
  ox_less 'less than {n} of [a], [b], ..., {conj} [z]'
  ox_more 'more than {n} of [a], [b], ..., {conj} [z]'
  ox_fewer 'fewer than {n} of [a], [b], ..., {conj} [z]'
  ox_greater 'greater than {n} of [a], [b], ..., {conj} [z]'
  ox_at_most 'at most {n} of [a], [b], ..., {conj} [z]'
  ox_at_least 'at least {n} of [a], [b], ..., {conj} [z]'
  ox_no_less 'no less than {n} of [a], [b], ..., {conj} [z]'
  ox_no_more 'no more than {n} of [a], [b], ..., {conj} [z]'
  ox_no_fewer 'no fewer than {n} of [a], [b], ..., {conj} [z]'
  ox_no_greater   'no greater than {n} of [a], [b], ..., {conj} [z]'
  ox_or_less '{n} or less of [a], [b], ..., {conj} [z]'
  ox_or_more '{n} or more of [a], [b], ..., {conj} [z]'
  ox_or_fewer '{n} or fewer of [a], [b], ..., {conj} [z]'
  ox_or_greater '{n} or greater of [a], [b], ..., {conj} [z]'

Value

A character scalar.

See Also

Other strings: blank(), chn(), delim(), fsub(), gr, ipat(), makestr(), markdown_help(), maxnch(), ox_vals(), pgrid_help(), revstr(), spaces(), ss_help(), tocase(), weave()

Examples

egFruits <- c("apples", "bananas", "oranges")

ox(egFruits)
ox("apples", "bananas", "orange")
ox_or(egFruits)
ox_and(egFruits)
ox_nor(egFruits)
ox_nor(egFruits, pref = "")

ox(egFruits)
ox(egFruits, conj = "or")
ox(egFruits, pref = "neither", conj = "nor")

ox(egFruits, pref = "", conj = "nor")
ox(egFruits, pref = "either", conj = "or")
ox(egFruits, pref = "all of", conj = "and")

ox_either(egFruits)
ox_either("apples", "bananas", "oranges")

ox_neither(egFruits)
ox_neither("apples", "bananas", "oranges")

ox_all(egFruits)
ox_all("apples", "bananas", "oranges")

ox_none(egFruits)
ox_none("apples", "bananas", "oranges")

ox_n(egFruits, n = 1)
ox_n(egFruits, conj = "and", n = 2, comp = "from among")
ox_n(egFruits, conj = "and", n = 2, comp = "at least", first = TRUE)
ox_n(egFruits, conj = "and", n = 2, comp = "or more", first = FALSE)

ox_exactly(egFruits, n = 2)
ox_less(egFruits, n = 2)
ox_more(egFruits, n = 2)
ox_fewer(egFruits, n = 2)
ox_greater(egFruits, n = 2)
ox_at_least(egFruits, n = 2)
ox_at_most(egFruits, n = 2)
ox_no_greater(egFruits, n = 2)
ox_no_fewer(egFruits, n = 2)
ox_no_more(egFruits, n = 2)
ox_no_less(egFruits, n = 2)
ox_or_more(egFruits, n = 2)
ox_or_greater(egFruits, n = 2)
ox_or_less(egFruits, n = 2)
ox_or_fewer(egFruits, n = 2)

j-martineau/uj documentation built on Sept. 14, 2024, 4:40 a.m.