ruedi ruedi - 1 year ago 98
R Question

Difference between environment and namespace

I know what a namespace is from other languages but in R I just cannot find a difference between the environment and namespace. Could anyone explain this since in the tutorials I have read (as The Art of R Programming and others) I just cannot find a distinction?

Answer Source

A namespace is something specific to a package. It is defined as a list of directive that allow you to import functions from other packages to be used locally or to export your functions and classes to be used in R. So if you have created in your package a function called foo you will add to your namespace something like export(foo) to make your function usable. If you want to import function from a specific package to use them in yours, you will add import(thePackage)

The environment is simply the space where you associate names to values. You can see it as a context in which you can evaluate functions and expressions.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download