merge_redundant_lists: Merge and Reduce List of Lists

Description Usage Arguments Examples

View source: R/annotate-terms.R

Description

General purpose function which takes a disorganized list and returns a sorted unique list of values.

Usage

1
2
merge_redundant_lists(l, input_delim = ";", output_delim = "",
  case_sensitive = FALSE)

Arguments

l

A list, data frame or vector. Lists and dataframes can be composed of mixtures of any other data type. Currently data frame columns encoded as factors are converted to their base structure (e.g. c("factor1", "factor2") -> c(1,2)). This can be fixed by using stringsAsFactors = TRUE for dataframe creation.

input_delim

Delimiter use to split combined strings into distinct values (e.g. "one; two; three" -> "one", "two", "three")

output_delim

Delimiter used to separate values in a single output string. Default blank value returns a list.

case_sensitive

Boolean indicating whether character case should be considered during comparison (e.g. case_sensitive = TRUE means "abc" != "ABC"). If the default FALSE value is used, all returned values are returned as lower case.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
l <- data.frame( a = c("one", "two"),
                 b = c(1,1),
                 c = c("two", "three"),
                 d = c(14, "zzz"),
                 stringsAsFactors = FALSE)
 merge_redundant_lists(l)
 merge_redundant_lists(l, output_delim = "; ")

 l<-list( c("before"),
          17,
          "R is cool",
          "A;B;C;D",
          "a;b;c;d",
          c(1,1,1))
 merge_redundant_lists(l, output_delim = ", ")

dkrozelle/toolboxR documentation built on Sept. 22, 2018, 11:45 p.m.