Learn R Programming

ThomasJeffersonUniv (version 0.1.3)

format_named: format_named

Description

format_named

Usage

format_named(x, sep = ": ", colored = TRUE)

Value

Function format_named returns a character

vector.

Arguments

x

character vector, or a list of character object. Input x must be named

sep

character scalar, see paste

colored

logical scalar, whether use two different color to separate each element, default TRUE

Examples

Run this code
x1 = c(a = 'a1', bc = '2\n3')
cat(format_named(x1), sep = '\n')
noout = lapply(format_named(x1), FUN = message)

x2 = list(a = '1\n2', b = character(), cd = '3\n4', efg = '5\n6\n7')
noout = lapply(format_named(x2, colored = FALSE), FUN = message)

x3 = c(a = '1\n2')
noout = lapply(format_named(x3), FUN = message)

Run the code above in your browser using DataLab