rm() function in R Language is used to delete objects from the memory. It can be used with ls() function to delete all objects. remove() function is also similar to rm() function.
Syntax: rm(x)
Parameters:
x: Object name
Example 1:
vec <- c(1, 2, 3, 4)
vec
list1 = list("Number" = c(1, 2, 3),
"Characters" = c("a", "b", "c"))
list1
mat <- matrix(c(1:9), 3, 3)
mat
rm(list1)
ls()
Output:
[1] 1 2 3 4
$Number
[1] 1 2 3
$Characters
[1] "a" "b" "c"
[, 1] [, 2] [, 3]
[1, ] 1 4 7
[2, ] 2 5 8
[3, ] 3 6 9
[1] "mat" "vec"
Example 2:
vec <- c(1, 2, 3, 4)
list1 = list("Number" = c(1, 2, 3),
"Characters" = c("a", "b", "c"))
mat <- matrix(c(1:9), 3, 3)
rm(list = ls())
ls()
Output:
character(0)
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
19 Jun, 2020
Like Article
Save Article