Richie Cotton
Richie Cotton

Reputation: 121057

What does the Autoloads environment do?

The second-to-last item on the search() path is (always?) an environment called Autoloads. All I could find about this topic is a sentence on page 26 of the R language definition (pdf).

An Autoloads environment is used for holding proxy objects that may be loaded on demand.

Please can you give me more of an explanation about what this is environment is used for.

Upvotes: 18

Views: 1205

Answers (1)

Richie Cotton
Richie Cotton

Reputation: 121057

Autoloading provides a way of loading packages in the future, only at the point at which they are used (if at all). So if a function from a package may soon be used, but (for memory reasons, perhaps) you don't want to load the package unless absolutely necessary, you can use the autoload function to promise to make a function available if it is used.

The Autoloads environment (accessible via as.environment("Autoloads") or .AutoloadEnv) stores the functions that it will promise to load and a character vector, .Autoloaded, that names the packages that need to be loaded.

Further information can be found in the ?autoload help page and R-FAQ 7.6.

Upvotes: 12

Related Questions