How can I generate a list of all the variables that have been assigned in an R language session?

  • $\begingroup$ Since this doesn't involve actual computations, it is off-topic here. It is likely better suited for the R forums or StackOverflow. $\endgroup$ Dec 5, 2013 at 19:40
  • 2
    $\begingroup$ I'm more inclined to keep it here for now, if it gets answered, because I believe it would fall under the header of "Software packages or languages used in computational science". If we get enough questions on R language syntax, then we can talk about migrating & clarifying our scope. I also agree this question would also be answered well on an R forum. Given our current traffic, I'd rather be permissive, build community, and narrow scope later with more data (and traffic) than exclude what looks reasonable for now. $\endgroup$ Dec 5, 2013 at 19:53

1 Answer 1


For the sake of completeness of the answer, you can use ls() to list all the assigned variables and data frames. This is similar to who and whos in Matlab.

If you want to get the list data.frames only you can use something like this:

ls()[grepl('data.frame', sapply(ls(), function(x) class(get(x))))]

You should probably ask questions like this on R forums.

  • $\begingroup$ I did not know about the R forum. Thanks! $\endgroup$ Dec 5, 2013 at 19:50
  • $\begingroup$ Basic programming questions are better off for Stack overflow (43055 questions with R tag). Cross validated has a lot of R-related material from the stats point of view (4984 questions with R tag). $\endgroup$
    – ivan-k
    Dec 5, 2013 at 19:54
  • $\begingroup$ Thank you very much. I stumbled upon this rich trove of knowledge so I am mapping my way. $\endgroup$ Dec 5, 2013 at 19:55

Not the answer you're looking for? Browse other questions tagged or ask your own question.