17) List Variables in R

This Blog entry is from the Getting Started in R section in Learn R.

While RStudio will display the variables in the session at a given point in time,  the function can be replicated to console also.  The ls() function,  which has hitherto been used to identify the functions in a package, is by default used to identify objects in the session.  In the script editor,  type:

ls()
the-ls-function-being-used-in-an-r-script.png

Run the line of script to console:

the-ls-function-written-out-to-r-console.png

The variable names are returned to the console.  To reference these,  it is simply a matter of typing the variable name:

String
taking-a-return-value-from-the-ls-function.png

Run the line of script to console:

writing-a-string-value-out-to-r-console.png