Print Names Of Objects in the Global Environment in R
How to see which objects you have in the global environment in R if you’re not using an IDE that shows them to you? Here’s one way to add them into a terminal message.
message_globalenv <- function() {
msg <- "R Global Environment:\n"
for (object in base::ls(name = base::globalenv(), all.names = TRUE)) {
msg <- paste0(msg, " * ", object, "\n")
}
message(msg)
}