List all the Objects present in the Current Working Directory in R Programming – ls() Function

ls() function in R Language is used to list the names of all the objects that are present in the working directory.

Syntax: ls()

Parameters:
This function needs no argument

Example 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

# R program to list all the object names
  
# Creating a vector
vec <- c(1, 2, 3)
  
# Creating a matrix
mat <- matrix(c(1:4), 2)
  
# Creating an array
arr <- array(c(1:4), 2)
  
# Calling ls() Function
ls()

chevron_right


Output:

[1] "arr" "mat" "vec"

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

# R program to list all the object names
  
# Creating a list
list1 = list("Numbers" = c(1:3), 
             "Characters" = c(1:5)) 
  
# Creating a Data frame
df = data.frame("Numbers" = c(1:3), 
                "Characters" = c(4:6)) 
  
# Calling ls() Function
ls()

chevron_right


Output:

[1] "df"    "list1"
My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.