uniques function

apply unique to each element of a list

apply unique to each element of a list

Apply unique to each element of a list, usually a list of vectors

uniques( x, keepNames = TRUE, incomparables = FALSE, useBioc = TRUE, useSimpleBioc = FALSE, xclass = NULL, ... )

Arguments

  • x: input list of vectors
  • keepNames: boolean indicating whether to keep the list element names in the returned results.
  • incomparables: see unique() for details, this value is only sent to S4Vectors::unique() when the Bioconductor package S4Vectors is installed, and is ignored otherwise for efficiency.
  • useBioc: logical, default TRUE, indicating whether this function should try to use S4Vectors::unique() when the Bioconductor package S4Vectors is installed, otherwise it will use a somewhat less efficient bulk operation.
  • useSimpleBioc: logical, default FALSE, whether to use a legacy mechanism with S4Vectors and is maintained for edge cases where it might be faster.
  • xclass: character optional vector of classes, used to invoke optimized logic when the class is known upfront.
  • ...: additional arguments are ignored.

Returns

list with unique values in each list element.

Details

This function will attempt to use S4Vectors::unique() which is substantially faster than any apply family function, especially for very long lists. However, when S4Vectors is not installed, it applies uniqueness to the unlisted vector of values, which is also substantially faster than the apply family functions for long lists, but which may still be less efficient than the C implementation provided by S4Vectors.

Examples

L1 <- list(CA=nameVector(LETTERS[c(1:4,2,7,4,6)]), B=letters[c(7:11,9,3)], C2=NULL, D=nameVector(LETTERS[4])); L1; uniques(L1); uniques(L1, useBioc=FALSE);

See Also

Other jam list functions: cPaste(), heads(), jam_rapply(), list2df(), mergeAllXY(), mixedSorts(), rbindList(), relist_named(), rlengths(), sclass(), sdim(), unnestList()

  • Maintainer: James M. Ward
  • License: MIT + file LICENSE
  • Last published: 2025-03-23