Open In App

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

Last Updated : 17 Jun, 2020
Comments
Improve
Suggest changes
Like Article
Like
Report
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: Python3 1==
# 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()
Output:
[1] "arr" "mat" "vec"
Example 2: Python3 1==
# 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()
Output:
[1] "df"    "list1"

Next Article
Article Tags :

Similar Reads