Skip to contents

Print named lists as formatted messages

Usage

lst2message(lst, indent = 0L, message = T, item_sep = "\n")

Arguments

lst

A list. Input to be printed.

indent

Integer. The number of spaces padded on the left of the output.

message

Logical. Whether to print the input as message. Defaults to TRUE. If FALSE, returns a character vector with formatted content.

item_sep

A string. The separator between the list elements. Defaults to \n.

name

description

Examples

lst2message(list(xyz = 1, xy = 2:3))
#> xyz: 1
#> xy : 2
#>      3
message("[Message]")
#> [Message]
#' lst2message(list(xyz = 1, xy = 2:3), indent=3)
lst2message(list(xyz = 1, xy = 2:3), message=F)
#> [1] "xyz: 1\nxy : 2\n     3"