misc.tools: grey.area misc.tools

misc.toolsR Documentation

grey.area misc.tools

Description

Some misc functions.

Usage

combinations(..., link = "<<>>", data = NULL)

uncombine(x, n = 1, splt = "<<>>")

Arguments

...

Unspecified or additional arguments. For combinations and uncombine vectors to be combined or uncombined, respectively.

link

(character) For combinations, the string to use as a separator when combining vectors.

data

(data.frame or similar) If supplied, the source for vectors to be combined.

x

(vector) For uncombine, a vector of previously combined terms to be uncombined.

n

(numeric) For uncombine, the combined vector to be extracted. The default 1 extracts the first vector of combined terms.

splt

(character) For uncombine, the separator previously used to combine vectors, used to split vectors when uncombining terms.

Value

combinations and uncombine return vectors of combined or uncombined terms, respectively.

Note

These are misc functions. They might need tidying

combinations merges supplied vectors but assumes the terms in the supplied vectors are equivalent. This is a little of a specialist function but if you ever have a case where e.g. you want to group journeys between locations and need a-to-b and b-to-a to be merged as a single case journeys-between-a-and-b...

uncombine extracts terms from a previous combined vector.

Author(s)

Katrina Hemingway and Karl Ropkins

Examples

a <- 1:5
b <- 5:1
#pasting combines two vectors
#making  e.g. 1 + 5 and 5 + 1 unique cases
paste(a,b)
#combinations makes cases where these are equivalent
combinations(a,b)

karlropkins/grey.area documentation built on Dec. 27, 2024, 7:10 p.m.