How to remove hidden R variables from within a function?

时间:2018-03-23 00:38:12

标签: r

I'm trying to remove an R variable prefixed by a . from within a function call. I am receiving an error that the variable cannot be found, even though it exists and I can remove it with no issues with remove():

> .a = "a"
> .a
[1] "a"
> remove(.a)
> .a
Error: object '.a' not found

However, If I wrap this remove call inside a function then I get an error even though .a exists:

> .a = "a"
> .a
[1] "a"
> Clear <-function(){remove(.a)}
> Clear()
Warning message:
In remove(.a) : object '.a' not found

> .a
[1] "a"

Is there a reason for this behaviour?

0 个答案:

没有答案