7.4 Internal state

Storing user-specific or system-specific data that functions need, but that cannot be known until the package is loaded

Use this method when:

  • Info needs to be determined at load time, or info is dynamic
  • It’s cumbersome or hard for the user to pass the info in as a function argument

Example use cases:

  • Allow user to get/set a list of information
  • Functions need to know the current project directory (e.g. usethis)
  • Functions need to know the user’s home directory on Google Drive (e.g. googledrive)

For more info: Package-Wide Variables/Cache in R Packages