getFromNamespace            package:utils            R Documentation

_U_t_i_l_i_t_y _f_u_n_c_t_i_o_n_s _f_o_r _D_e_v_e_l_o_p_i_n_g _N_a_m_e_s_p_a_c_e_s

_D_e_s_c_r_i_p_t_i_o_n:

     Utility functions to access and replace the non-exported functions
     in a namespace, for use in developing packages with namespaces.

_U_s_a_g_e:

     getFromNamespace(x, ns, pos = -1, envir = as.environment(pos))

     assignInNamespace(x, value, ns, pos = -1,
                       envir = as.environment(pos))

     fixInNamespace(x, ns, pos = -1, envir = as.environment(pos), ...)

_A_r_g_u_m_e_n_t_s:

       x: an object name (given as a character string).

   value: an R object.

      ns: a namespace, or character string giving the namespace.

     pos: where to look for the object: see 'get'.

   envir: an alternative way to specify an environment to look in.

     ...: arguments to pass to the editor: see 'edit'.

_D_e_t_a_i_l_s:

     The namespace can be specified in several ways.  Using, for
     example, 'ns = "stats"' is the most direct, but a loaded package
     with a namespace can be specified via any of the methods used for
     'get': 'ns' can also be the environment printed as
     '<namespace:foo>'.

     'getFromNamespace' is similar to (but predates) the ':::'
     operator, but is more flexible in how the namespace is specified.

     'fixInNamespace' invokes 'edit' on the object named 'x' and
     assigns the revised object in place of the original object.  For
     compatibility with 'fix', 'x' can be unquoted.

_V_a_l_u_e:

     'getFromNamespace' returns the object found (or gives an error).

     'assignInNamespace' and 'fixInNamespace' are invoked for their
     side effect of changing the object in the namespace.

_N_o_t_e:

     'assignInNamespace' and 'fixInNamespace' change the copy in the
     namespace, but not any copies already exported from the namespace,
     in particular an object of that name in the package (if already
     attached) and any copies already imported into other namespaces.
     They are really intended to be used _only_ for objects which are
     not exported from the namespace.  They do attempt to alter a copy
     registered as an S3 method if one is found.

     They can only be used to change the values of objects in the
     namespace, not to create new objects.

_S_e_e _A_l_s_o:

     'get', 'fix', 'getS3method'

_E_x_a_m_p_l_e_s:

     getFromNamespace("findGeneric", "utils")
     ## Not run: 
     fixInNamespace("predict.ppr", "stats")
     stats:::predict.ppr
     getS3method("predict", "ppr")
     ## alternatively
     fixInNamespace("predict.ppr", pos = 3)
     fixInNamespace("predict.ppr", pos = "package:stats")
     ## End(Not run)

