[R] Help with namespace
Doran, Harold
HDoran at air.org
Mon Oct 26 19:56:30 CET 2009
> -----Original Message-----
> From: Duncan Murdoch [mailto:murdoch at stats.uwo.ca]
> Sent: Monday, October 26, 2009 2:29 PM
> To: Doran, Harold
> Cc: r-help at r-project.org
> Subject: Re: [R] Help with namespace
>
> On 10/26/2009 1:43 PM, Doran, Harold wrote:
> > I'm having a little trouble building a package with a
> namespace. Suppose I have two functions: g and f and I want
> to build the package foo. Suppose f is a function that has an
> internal purpose and should not be visible to the user.
> Additionally, I do not want to write a help (Rd) file for f.
> The only function that should be visible to the user and have
> an associated help function is g.
> >
> > First off, if I follow the normal (windows-based)
> procedures for building this package without the namespace I
> have no problems. I do build, check, and install all without
> fail and can use these functions in an R session.
> >
> > Now, I add in a namespace file in the top level directory
> and, following the namespace example found at the link below,
> I construct a namespace that has the following in it:
> >
> > ### begin namespace file
> > useDynLib(foo)
>
> Two questions:
>
> Do you really have C or Fortran or other external source code
> in your src directory? That should be compiled into foo.dll,
> and useDynLib is looking for it. But the error below
> indicates that didn't happen.
No, no external source code. I'll drop this.
>
> If you don't have any external code, you don't want the
> useDynLib line.
>
> And did you really call it "namespace"? It should be called
> "NAMESPACE". On Windows either will work because it isn't
> case sensitive, but when you distribute to others, you may
> end up on a case sensitive file system, and you'd better get it right.
No, I called it NAMESPACE. Only my email was incorrect. Now, if my NAMESPACE file has the following text (and only this text), then build, check, and install work fine.
### begin NAMESPACE
exportPattern("^[[:alpha:]]+")
### end NAMESPACE
However, I don't believe this accomplishes what I aim for. When I do this, I need a proper f.Rd file.
>
> > export(g)
> > ### end namespace file
> > http://cran.r-project.org/doc/manuals/R-exts.html#An-example
> >
> > Because I don't want there to be an .Rd file for the
> function f I remove it from the "man" directory. I say remove
> because I use package.skeleton() and it automatically creates
> an empty .Rd file for the function f. This leaves only g.Rd
> and foo-package.Rd in the man directory.
> >
> > After running Rcmd check foo, I get the following:
> >
> > C:\Program Files\R\R-2.9.2\bin>Rcmd check g:\foo
> > * checking for working pdflatex ...pdflatex: not found NO
> > * checking for working latex ...latex: not found NO
> > * using log directory 'C:/Program Files/R/R-2.9.2/bin/foo.Rcheck'
> > * using R version 2.9.2 (2009-08-24)
> > * using session charset: ISO8859-1
> > * checking for file 'foo/DESCRIPTION' ... OK
> > * checking extension type ... Package
> > * this is package 'foo' version '1.0'
> > * checking package name space information ... OK
> > * checking package dependencies ... OK
> > * checking if this is a source package ... OK
> > * checking for .dll and .exe files ... OK
> > * checking whether package 'foo' can be installed ... OK
> > * checking package directory ... OK
> > * checking for portable file names ... OK
> > * checking DESCRIPTION meta-information ... OK
> > * checking top-level files ... OK
> > * checking index information ... OK
> > * checking package subdirectories ... OK
> > * checking R files for non-ASCII characters ... OK
> > * checking R files for syntax errors ... OK
> > * checking whether the package can be loaded ... ERROR Error in
> > library.dynam(lib, package, package.lib) :
> > shared library 'foo' not found
> > Error: package/namespace load failed for 'foo'
> > Execution halted
> >
> > It looks like this package has a loading problem: see the
> messages for
> > details.
> >
> > The fact that latex is not found baffles me, but that's
> another issue which is ancillary to my problem. But, just for
> completeness, it is installed, it is in the path as directed
> by Duncan Murdoch's website for building R packages
> indicates. I've built packages many times before even though
> this error exists.
>
> Does "pdflatex --version" work at the command line? What
> does it tell you?
>
> Duncan Murdoch
>
> >
> > I think I am missing some understanding of how the
> namespace should be properly developed and used in the
> construction of the package. Any insight into my errors is
> appreciated.
> >
> > Harold
> >
> >
> >
> >> sessionInfo()
> > R version 2.9.2 (2009-08-24)
> > i386-pc-mingw32
> >
> > locale:
> > LC_COLLATE=English_United States.1252;LC_CTYPE=English_United
> > States.1252;LC_MONETARY=English_United
> > States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252
> >
> > attached base packages:
> > [1] stats graphics grDevices utils datasets
> methods base
> > ______________________________________________
> > 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