While making a list of objectives, is there a way of retaining the object symbols to use them as names on the list?
The below uses to get and re-assigns names afterward, and I wondered if there is another approach.
a_1 <- 1
a_2 <- 2
a_3 <- 3
ls_a <- lapply(ls(pattern = "a_"), get)
names(ls_a) <- ls(pattern = "a_")
ls_a
#> $a_1
#> [1] 1
#>
#> $a_2
#> [1] 2
#>
#> $a_3
#> [1] 3