compact_vec: Compacting a vector of any length with or without names

View source: R/ds2dd_detailed.R

compact_vecR Documentation

Compacting a vector of any length with or without names

Description

Compacting a vector of any length with or without names

Usage

compact_vec(data, nm.sep = ": ", val.sep = "; ")

Arguments

data

vector, optionally named

nm.sep

string separating name from value if any

val.sep

string separating values

Value

character string

Examples

sample(seq_len(4), 20, TRUE) |>
  as_factor() |>
  named_levels() |>
  sort() |>
  compact_vec()
1:6 |> compact_vec()
"test" |> compact_vec()
sample(letters[1:9], 20, TRUE) |> compact_vec()

REDCapCAST documentation built on April 4, 2025, 3:18 a.m.