Several answers of Ramnath.
To get multiple objects, it is preferable to use mget
instead of get
with lapply
.
all <- mget(ls(), envir = globalenv())
You can use Filter
to filter the list of variables. I think this makes the code more clear. (Although he does the same under the hood.)
Filter(function(x) attr(x, "foo") == "bar", all)
source share