ff_sup_lst2str: This function converts a list of strings to a single string...

Description Usage Arguments Value Author(s) References Examples

View source: R/ff_sup_string.R

Description

Collapases list of string to a single string with some concatenation. Also prints out the lst_list code itself for easier identification of what is been printed

Usage

1
ff_sup_lst2str(ls_list, st_desc, bl_print = FALSE)

Arguments

ls_list

named or unamed list of strings or numerical values

st_desc

if this is provided, will use this as the string description in print, otherwise will print out the ls_list code itself

bl_print

if TRUE, will print twice if output not saved in variable

Value

a string that collapses a list with description up front

Author(s)

Fan Wang, http://fanwangecon.github.io

References

https://fanwangecon.github.io/R4Econ/amto/list/htmlpdfr/fs_lst_basics.html https://github.com/FanWangEcon/REconTools/blob/master/R/ff_sup_string.R

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
# Define Lists
ls_num <- list(1,2,3)
ls_str <- list('1','2','3')
ls_num_str <- list(1,2,'3')

# Named Lists
ar_st_names <- c('e1','e2','e3')
ls_num_str_named <- ls_num_str
names(ls_num_str_named) <- ar_st_names

# Add Element to Named List
ls_num_str_named$e4 <- 'this is added'

ff_sup_lst2str(ls_num)
ff_sup_lst2str(ls_str)
ff_sup_lst2str(ls_num_str)
ff_sup_lst2str(ls_num_str_named)

ff_sup_lst2str(ls_num[2:3])
ff_sup_lst2str(ls_str[2:3])
ff_sup_lst2str(ls_num_str[2:4])
ff_sup_lst2str(ls_num_str_named[c('e2','e3','e4')])

FanWangEcon/REconTools documentation built on Jan. 21, 2022, 10:28 p.m.