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

Katharine Mullen kate at few.vu.nl
Tue Nov 6 21:52:07 CET 2007


OK, well, the way I suggested will allow you to modify the C code too --
but reading your question I realize you probably don't want to do this.
If you want to use the definitions of the C functions from stats, you can
skip 2. below and add another modification to the calls to .C in your
def. of bw.SJ; add the argument PACKAGE="stats".

On Tue, 6 Nov 2007, Katharine Mullen wrote:

> bw.SJ calls C code from the file
> /usr/local/bin/R-2.6.0/src/library/stats/src/bandwidths.c
> You have to make this code available.
>
> You can do the following:
> 1. copy bandwidths.c and the definition of bw.SJ (the latter renamed) to a
> directory
> 2. compile bandwidths.c into a shared library with the command
> R CMD SHLIB bandwidths.c (see the manual writing R extensions for details)
> 3. in your definition of bw.SJ, in the 3 places .C is
> called, remove "R_" from the first argument and quote it; e.g.,
> C(R_band_phi4_bin, ..." becomes "C("band_phi4_bin","
> 4. in R, load the shared library you built with the dyn.load function; now
> your definition of the (renamed) function bw.SJ can be modified as you
> like.
>
> On Tue, 6 Nov 2007, Jason Liao wrote:
>
> >
> >  I tried to modify the R function bw.SJ (from the stats package) for my
> > own use. But if I just get the source code and run directly (without any
> > modification), it can no longer find some key functions called within
> > it. I understand this has something to do with searching path which I do
> > not understand well. Can anyone tell me how to modify the source code of
> > an R function and still make it part of an existing package?
> >
> > Thanks.
> >
> >
> > Jason Liao, http://www.geocities.com/jg_liao
> > Associate Professor of Biostatistics
> > Drexel University School of Public Health
> > 245 N. 15th Street, Mail Stop 660
> > Philadelphia, PA 19102-1192
> > phone 215-762-3934
> >
> > ______________________________________________
> > R-help at r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list