strsplitOrdered: Split the elements of an ordered factor vector

strsplitOrderedR Documentation

Split the elements of an ordered factor vector

Description

Split the elements of an ordered factor vector

Usage

strsplitOrdered(
  x,
  split = "_",
  fixed = FALSE,
  perl = FALSE,
  useBytes = FALSE,
  sortFunc = jamba::mixedSort,
  keepOrder = TRUE,
  ...
)

Arguments

x

character or factor vector.

split

character split value sent to base::strsplit().

fixed, perl, useBytes

additional arguments sent to base::split().

sortFunc

function used to sort character values when the input x is a character vector. The default jamba::mixedSort() applies alphanumeric sort.

keepOrder

logical indicating whether to keep the order of values in the input data, for example with character input the values will be ordered by the first appearance of each term.

...

additional arguments are ignored.

Details

This function performs base::strsplit() while trying to maintain the order of factor levels in the output, based upon the order of factor levels in the input data.

Value

list of factor vectors, where each factor shares the same global factor levels based upon the input data.

See Also

Other jam string functions: escapeWhitespaceRegexp(), sortSamples()

Examples

# first define a vector of sample groups
iGroups <- jamba::nameVector(paste(rep(c("WT", "KO"), each=6),
   rep(c("Control", "Treated"), each=3),
   sep="_"));
iGroups <- factor(iGroups, levels=unique(iGroups));
iGroups;
strsplitOrdered(iGroups, "_");


jmw86069/splicejam documentation built on Nov. 4, 2024, 10:53 a.m.