Re: [Rd] "could not find function" in R CMD check [solved, but is this an R bug?]

From: Ross Boylan <ross_at_biostat.ucsf.edu>
Date: Wed, 12 Sep 2007 12:54:48 -0700

On Wed, 2007-09-12 at 11:31 +0200, Uwe Ligges wrote:
> Perhaps Namespace issues? But no further ideas. You might want to make
> your package available at some URL so that people can look at it and help...
>
> Uwe Ligges
>
Thanks. The problem lay elsewhere. I was able to fix it by adding library(mspath)
to the top of the .R file in data/ that defined some data using the package's functions In other words



library(mspath)
### from various papers on errors in reading fibrosis scores rousselet.jr <- readingError(c(.91, .09, 0, 0, 0,
                               .11, .78, .11, 0, 0,
                               0, .17, .75, .08, 0,
                               0, .06, .44, .50, 0,
                               0, 0, 0, .07, .93),
                             byrow=TRUE, nrow=5, ncol=5)
-----------------------------------------------------
works as data/readingErrorData.R, but without the library() call I get the error shown in my original message (see below). readingError() is a function defined in my package.

Does any of this inndicate a bug or undesirable feature in R?

First, it seems a little odd that I need to include loading the library in data that is defined in the same library. I think I've noticed similar behavior in other places, maybe the code snippets that accompany the documentation pages (that is, one needs library(mypackage) in order for the snippets to check out).

Second, should R CMD check fail so completely and opaquely in this situation?

>
> Ross Boylan wrote:
> > During R CMD check I get this:
> > ** building package indices ...
> > Error in eval(expr, envir, enclos) : could not find function
> > "readingError"
> > Execution halted
> > ERROR: installing package indices failed
> >
> > The check aborts there. readingError is a function I just added; for
> > reference
> > setClass("readingError", contains="matrix")
> > readingError <- function(...) new("readingError", matrix(...))
> > which is in readingError.R in the project's R subdirectory.
> >
> > Some code in the data directory invokes readingError, and the .Rd file
> > includes \alias{readingError}, \alias{readingError-class},
> > \name{readingError-class} and an example invoking readingError.
> >
> > I'm using R 2.5.1 as packaged for Debian GNU/Linux.
> >
> > Does anyone have an idea what's going wrong here, or how to fix or debug
> > it?
> >
> > The code seems to work OK when I use it from ESS.



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Wed 12 Sep 2007 - 19:57:27 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 12 Sep 2007 - 20:41:57 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.