0

I would like to obtain the class information (e.g. dataframe, sf object, etc.) on all data objects in my global environment at once without having to run code like this:

class(data1)
class(data2)
class(data3)

and so on. I have tried ls.str() and while that does technically achieve the goal, it gives me far more information than I am wanting at a single time. I want to display only the class of each object that is in the global environment.

TRS6
  • 99
  • 5
  • 1
    Do you mean this: `l <- mget(ls(), envir = globalenv()); lapply(l, \(x) class(x))`? – Quinten Feb 02 '23 at 17:53
  • 2
    Or without the temp var: `sapply(mget(ls(envir= globalenv())), class)` – MrFlick Feb 02 '23 at 17:53
  • Note that `class()` for a given object can be a vector of values. An object doesn't necessarily have just once "class" string. For example `class(dplyr::tibble())` – MrFlick Feb 02 '23 at 17:58

0 Answers0