R/col_to_lst_col.R

Defines functions col_to_lst_col

col_to_lst_col <- function(x, sep = "|", unique = TRUE, sort = TRUE) {

  if (rlang::is_empty(x)) return(list())

  lst_col <-
    strsplit(x, split = sep, fixed = TRUE) |>
    lst_col_na_to_empty()

  if (unique) lst_col <- sapply(lst_col, \(.x) unique(.x))
  if (sort) lst_col <- sapply(lst_col, \(.x) sort(.x))

  lst_col
}

Try the mgi.report.reader package in your browser

Any scripts or data that you put into this service are public.

mgi.report.reader documentation built on Sept. 11, 2024, 8:41 p.m.