[R] import function without overwriting function with the same name

Martin Batholdy batholdy at googlemail.com
Sat Aug 3 22:27:03 CEST 2013


Hi,

I have to import multiple R-files.
Each file consists of several functions with the same function name across the R-files.

When I import all files one by one (with source()) I overwrite the function definition of the previous file until only the very last function definition lasts.
However, I need them separately (although they have the name, they solve a certain task differently).

Now I thought about creating a separate environment for each file / function-group, but I do not know upfront how many files I have to import and therefore how many different environments I need.
But since the creation of an environment works like variable assignments (myEnv <- new.env()) I cannot just loop over the number of files and create x environments.

What is the best way to solve this problem of importing functions without overwriting already existing functions with the same name?


Thanks!


More information about the R-help mailing list