R implicit remove of object
ls()
gives among others and the following object: object2remove
Next we have the following code:
variableIuse <- "object2remove"
The question 开发者_开发百科is:
How do I remove implicitly object2remove
through the variableIuse
?
You need to use the list
parameter of the rm()
function:
> object2remove <- 1:10
> variableIuse <- 'object2remove'
> rm(list = variableIuse) # remove variable named by variableIuse
> variableIuse # still exists
[1] "object2remove"
> object2remove # no longer exists
Error: object 'object2remove' not found
精彩评论