Skip to content
Prev 26605 / 63424 Next

help needed: taking a function out of a package and it can not find some funtions

I do wonder when you would consider something a programming question 
unsuitable for R-help?  See the posting guide.

At least my answer needs to be on R-devel.
On Tue, 6 Nov 2007, Jason Liao wrote:

            
That's not what I find.  The missing objects are not functions for me.
You don't want to do that.  The issue is being in the stats namespace, and 
if you need to ask how to add a function to that namespace, you don't know 
enough to be doing so.

You can get away (or at least, I did) with modifying the source of bw.SJ 
as follows:

     SDh <- function(x, h, n, d) .C(stats:::R_band_phi4_bin, as.integer(n),
         as.integer(length(x)), as.double(d), x, as.double(h),
         u = double(1))$u
     TDh <- function(x, h, n, d) .C(stats:::R_band_phi6_bin, as.integer(n),
         as.integer(length(x)), as.double(d), x, as.double(h),
         u = double(1))$u
     Z <- .C(stats:::R_band_den_bin, as.integer(n), as.integer(nb), d = double(1),
         x, cnt = integer(nb))

Alternatively, you don't need the function to be in the stats namespace, 
just to have the stats namespace as its environment. Again, that is 
something that is not recommended, but

environment(my.bw.SJ) <- environment(bw.SJ)

would do it.