Some misc functions.
Arguments
- ...
Unspecified or additional arguments. For
combinations
anduncombine
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 default1
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.
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.
Examples
a <- 1:5
b <- 5:1
#pasting combines two vectors
#making e.g. 1 + 5 and 5 + 1 unique cases
paste(a,b)
#> [1] "1 5" "2 4" "3 3" "4 2" "5 1"
#combinations makes cases where these are equivalent
combinations(a,b)
#> [1] "1<<>>5" "2<<>>4" "3<<>>3" "2<<>>4" "1<<>>5"