kpwNames: Collapse and paste Elements With Names

View source: R/Stringendo.R

kpwNamesR Documentation

Collapse and paste Elements With Names

Description

This function takes a named vector and returns a string where each element is pasted with its name. Elements are separated by a specified string, and name-element pairs are also separated by a specified string. The default named vector is c('a' = 1, 'b' = 2).

Usage

kpwNames(
  x = c(a = 1, b = 2),
  sep1 = ": ",
  sep2 = " | ",
  prefix = NULL,
  suffix = NULL
)

Arguments

x

A named vector. Default is c('a' = 1, 'b' = 2).

sep1

A character string to separate the names from the elements. Default is ":".

sep2

A character string to separate the name-element pairs in the resulting string. Default is " ".

prefix

A character string to add to the beginning of the resulting string. Default is NULL.

suffix

A character string to add to the end of the resulting string. Default is NULL.

Examples

kpwNames(c("a" = 1, "b" = 2))

vertesy/Stringendo documentation built on Nov. 10, 2024, 4:35 a.m.