R Program to get the details of the objects in memory

How to get the details of the objects in memory

Here we are explaining how to write an R program to get the details of the objects in memory. Here we are using built-in functions ls() means list objects for this calculation. The ls() helps to return a vector of character strings with the names of the objects in the specified environment. If we called this function without arguments it will give the data sets and functions that a user has defined. And the ls.str is used for a long listing based on the str.

 

How to get the details of the objects in memory in R Program

Below are the steps used in the R program to get the details of the objects in memory. In this R program, we directly give the values to variables name,num1,num2, nums. And print the function result. Here the variable name is assigned with a string num1 with an integer value,num2 with floating value, and nums with vector values.

ALGORITHM

STEP 1: Assign variable name,num1,num2, nums with corresponding values

STEP 2: Call the built-in functions ls() for a listing of objects

STEP 3: First print given objects

STEP 4: Call the built-in functions ls.str() for string based long listing

 

R Source Code

                                          name = "Python"; 
num1 =  8; 
num2 =  1.5
nums = c(10, 20, 30, 40, 50, 60)
print(ls())
print("Details of the objects in memory:")
print(ls.str())

                                      

OUTPUT

[1] "num1"   "num2"   "name" "nums"
[1] "Details of the objects in memory:"
num1 :  num 8
num2 :  num 1.5
name :  chr "Python"
nums :  num [1:6] 10 20 30 40 50 60