7

Possible Duplicate:
Masked functions in R
R: Masked Functions
function naming conflicts

If I have two packages: A and B. Say there is function named funfun in A and there is function named funfun in B too. When I load A and B, how do I use the first funfun?

require(A)
require(B)

If I want to use funfun in A, how do I write this?

Community
  • 1
  • 1
Peng Peng
  • 1,305
  • 3
  • 16
  • 20
  • 1
    Some near duplicates: http://stackoverflow.com/questions/2842120/masked-functions-in-r, http://stackoverflow.com/questions/4879377/r-masked-functions, http://stackoverflow.com/questions/9337716/how-do-i-use-functions-in-one-r-package-masked-by-another-package – Andrie Jul 27 '12 at 08:40

1 Answers1

10

You can explictily refer to a package and function combination like this:

A::funfun
B::funfun

In unusual circumstances, you may have to refer to functions that are not exported in the namespace, in which case you need to use:

A:::funfun
B:::funfun

(But this would be unusual, and since non-exported functions do not form part of the package API, these functions could change without warning in subsequent releases of a package.)

Andrie
  • 176,377
  • 47
  • 447
  • 496
Paul Hiemstra
  • 59,984
  • 12
  • 142
  • 149
  • 2
    If the function is exported you may only need to use `::`. – IRTFM Jul 27 '12 at 07:47
  • 4
    +1 Strictly speaking, `:::` allows access to functions that are not exported in the package namespace - this isn't something that most users should have to do. Since I think it's more appropriate to use `::` I have edited the answer. – Andrie Jul 27 '12 at 08:36