Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't rm object in R?

Tags:

r

In my console ,i can not delete objects ,why?

> ls()
[1] "f1"      "f2"      "getmail" "k"       "mail"    "pattern" "rm"      "word"    "x"      
> rm(k)
Error in rm(k) : unused argument(s) (k)
> rm("k")
Error in rm("k") : unused argument(s) ("k")
like image 898
Dada Lili Avatar asked Nov 18 '25 06:11

Dada Lili


1 Answers

You have overwritten the rm object with an own object called rm:

> ls()
[1] "f1"      "f2"      "getmail" "k"       "mail"    "pattern" "rm"      "word"    "x"      

So when you write rm(something) it’s not calling the original rm but your own. To call the original rm, use

originalRm <- get('rm', baseenv())
originalRm(object)

# or, simpler:

base::rm(object)
like image 90
Konrad Rudolph Avatar answered Nov 20 '25 21:11

Konrad Rudolph