0

I often have variables in cells that I do not need again. Say a loop index or just an intermediate result. These build up in the list of variables in RStudio, and it does not make it easier to work with.

Therefore I would like to mark those “cell local” variables such that they are not used in other cells. I am using underscores instead of dots to separate words in identifiers, sticking with Hadley Wickam's guideline.

One convention that I have seen is prefixing with a dot. Does that make sense in this case? Or rather an underscore, like in Python?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Martin Ueding
  • 8,245
  • 6
  • 46
  • 92
  • 1
    Might clear things up: https://stackoverflow.com/a/7526926/1777111 Starting a variable or function name with an underscore does not work. – Martin Schmelzer Dec 14 '17 at 15:00

1 Answers1

0

I assume you mean "chunk local." There is nothing automatic I know of, but if you a convention like a leading ., you can periodically run something like

 rm(grep("^.", ls(), value=TRUE))

in a chunk

user101089
  • 3,756
  • 1
  • 26
  • 53