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 name space, for use in developing packages with name spaces.

_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 name space, or character string giving the name space.

     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 name space can be specified in several ways.  Using, for
     example, 'ns = "stats"' is the most direct, but a loaded package
     with a name space 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 name space 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 name space.

_N_o_t_e:

     'assignInNamespace' and 'fixInNamespace' change the copy in the
     name space, but not any copies already exported from the name
     space, in particular an object of that name in the package (if
     already attached) and any copies already imported into other name
     spaces. They are really intended to be used _only_ for objects
     which are not exported from the name space.  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 name
     space, 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)

