How to List Workspace Variables in R


R uses a global workspace to manage current state. This is obvious when using R Studio where you workspace details are in panels on the right. There are many functions to help you manage with workspace. In this article, we will look at how to list all variables in your workspace.

To list all variables in our workspace, we begin by creating a few variables. We can then use the ls function to get a list of variable names.

x = 10
y = "string"
list = c(1, 2, 3)


#> [1] "x" "y" "list"

We can also get more details if we use the ls.str function.


#> x :  num 10
#> y :  str 
#> list : num[1:3]