R/ff_sup_string.R
ff_sup_lst2str.Rd
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
ff_sup_lst2str(ls_list, st_desc, bl_print = FALSE)
named or unamed list of strings or numerical values
if this is provided, will use this as the string description in print, otherwise will print out the ls_list code itself
if TRUE, will print twice if output not saved in variable
a string that collapses a list with description up front
https://fanwangecon.github.io/R4Econ/amto/list/htmlpdfr/fs_lst_basics.html https://github.com/FanWangEcon/REconTools/blob/master/R/ff_sup_string.R
# 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)
#> [1] "ls_num:=1;=2;=3"
ff_sup_lst2str(ls_str)
#> [1] "ls_str:=1;=2;=3"
ff_sup_lst2str(ls_num_str)
#> [1] "ls_num_str:=1;=2;=3"
ff_sup_lst2str(ls_num_str_named)
#> [1] "ls_num_str_named:e1=1;e2=2;e3=3;e4=this is added"
ff_sup_lst2str(ls_num[2:3])
#> [1] "ls_num[2:3]:=2;=3"
ff_sup_lst2str(ls_str[2:3])
#> [1] "ls_str[2:3]:=2;=3"
ff_sup_lst2str(ls_num_str[2:4])
#> [1] "ls_num_str[2:4]:=2;=3;=NULL"
ff_sup_lst2str(ls_num_str_named[c('e2','e3','e4')])
#> [1] "ls_num_str_named[c(\"e2\", \"e3\", \"e4\")]:e2=2;e3=3;e4=this is added"