How to Apply the objects() & ls() Functions in R (Example Code)

In this article you’ll learn how to apply the ls() and objects() functions in the R programming language.

Introduction of Example Data

data(iris)                     # Create some example data
vec <- 1:5
my_list <- list(1, 2, 3)

Example: Print Names of Objects in Environment Using objects() & ls() Functions

objects()                      # Using objects() function
# [1] "iris" "vec" "my_list"
ls()                           # Using ls() function
# [1] "iris" "vec" "my_list"

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.
You need to agree with the terms to proceed