문제

I have a file with an R program. I load it interactively on R and then I call the main function. During the execution I fill up some global lists but when I run the main function again I want those lists to be empty. How can I empty a filled up list? I tried doing

list <- NULL

after execution but it didn't work.

도움이 되었습니까?

해결책

Since you are setting them globally, you probably need list <<- NULL, because the <<- operator assigns global variables.

Edit, per @Dason's comment:

The <<- operator can in some circumstances fail to change the value of a variable in all possible environments. For that reason, it is better to use

assign("list", NULL, envir = .GlobalEnv)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top