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)