I cannot find out how to list and print all objects in a workspace. I’d like to see them all and understand what’s going on. For example, ls() gives you 30 objects. How, besides typing them individually, is it possible to display them all. Seems so trivial, the solution will probably quite embarrasing. The closest I’ve come was ls.str() and the idea of looping over the objects.
Edit: This is not for data frames. I have a workspace full of functions, without data, and like to understand which ones reference which etc.
Do you mean ‘display’ in the sense of “for every object in
ls(), I want to see what I would see if I typed it into the prompt”? What if you have some matrix that’s 1000×10000 – you still want to print it? I personally likels.str()– I think it gives a nice concise overview of everything, and handles the case I just mentioned nicely.However if you want to basically “display” every object in the sense of typing each on the prompt, I’d suggest a loop:
Since
ls()returns a character vector of variable names, I need to useget(obj)which gets the variable whose name is inobj.You may wish to do a variation of this in order to print the variable name too, e.g.
As an example:
This does have a drawback though – next time you call
ls()there’s now anobjin there. I’m sure there’s some workaround though.Anyhow, I think I still prefer
ls.str()for the way it handles big objects (but I work with a lot of huge (millions of elements) matrices, so that’s my preference).