循环浏览并获取名称:
# example lists
plot_overall_chem <- list(one = 1, two = 2)
plot_overall_hema <- list(three = 3, four = 4)
unlist(lapply(ls(pattern = "plot_"), function(i) names(get(i))))
# [1] "one" "two" "three" "four
要保留我们可以堆叠的名单名称:
stack(sapply(ls(pattern = "plot_"), function(i) names(get(i)), simplify = FALSE))
# values ind
# 1 one plot_overall_chem
# 2 two plot_overall_chem
# 3 three plot_overall_hema
# 4 four plot_overall_hema