Rebecca Sela
2009-May-13 18:38 UTC
[R] Checking a (new) package - examples require other package functions
I am creating an R package. I ran R CMD check on the package, and everything passed until it tried to run the examples. Then, the result was: * checking examples ... ERROR Running examples in REEMtree-Ex.R failed. The error most likely occurred in:> ### * AutoCorrelationLRtest > > flush(stderr()); flush(stdout()) > > ### Name: AutoCorrelationLRtest > ### Title: Test for autocorrelation in the residuals of a RE-EM tree > ### Aliases: AutoCorrelationLRtest > ### Keywords: htest tree models > > ### ** Examples > > # Estimation without autocorrelation > simpleEMresult<-RandomEffectsTree(Y~D+t+X, data=simpleREEMdata, random=~1|ID, simpleREEMdata$ID)Error: couldn't find function "RandomEffectsTree" Execution halted The function "RandomEffectsTree" is defined in the R code for the package. How can I refer to other functions from the package in examples? (I have the "Writing R-extensions" PDF, so it would be enough to point me to the right page, if the answer is in there and I just missed it.) Thanks! Rebecca
Tony Plate
2009-May-13 20:04 UTC
[R] Checking a (new) package - examples require other package functions
Did you try putting library("your-package-name", char=TRUE) at the start of the examples? -- Tony Plate Rebecca Sela wrote:> I am creating an R package. I ran R CMD check on the package, and everything passed until it tried to run the examples. Then, the result was: > > * checking examples ... ERROR > Running examples in REEMtree-Ex.R failed. > The error most likely occurred in: > >> ### * AutoCorrelationLRtest >> >> flush(stderr()); flush(stdout()) >> >> ### Name: AutoCorrelationLRtest >> ### Title: Test for autocorrelation in the residuals of a RE-EM tree >> ### Aliases: AutoCorrelationLRtest >> ### Keywords: htest tree models >> >> ### ** Examples >> >> # Estimation without autocorrelation >> simpleEMresult<-RandomEffectsTree(Y~D+t+X, data=simpleREEMdata, random=~1|ID, simpleREEMdata$ID) > Error: couldn't find function "RandomEffectsTree" > Execution halted > > > The function "RandomEffectsTree" is defined in the R code for the package. How can I refer to other functions from the package in examples? (I have the "Writing R-extensions" PDF, so it would be enough to point me to the right page, if the answer is in there and I just missed it.) > > Thanks! > > Rebecca > > ______________________________________________ > 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. >
Duncan Murdoch
2009-May-14 10:57 UTC
[R] Checking a (new) package - examples require other package functions
On 13/05/2009 2:38 PM, Rebecca Sela wrote:> I am creating an R package. I ran R CMD check on the package, and everything passed until it tried to run the examples. Then, the result was: > > * checking examples ... ERROR > Running examples in REEMtree-Ex.R failed. > The error most likely occurred in: > >> ### * AutoCorrelationLRtest >> >> flush(stderr()); flush(stdout()) >> >> ### Name: AutoCorrelationLRtest >> ### Title: Test for autocorrelation in the residuals of a RE-EM tree >> ### Aliases: AutoCorrelationLRtest >> ### Keywords: htest tree models >> >> ### ** Examples >> >> # Estimation without autocorrelation >> simpleEMresult<-RandomEffectsTree(Y~D+t+X, data=simpleREEMdata, random=~1|ID, simpleREEMdata$ID) > Error: couldn't find function "RandomEffectsTree" > Execution halted > > > The function "RandomEffectsTree" is defined in the R code for the package. How can I refer to other functions from the package in examples? (I have the "Writing R-extensions" PDF, so it would be enough to point me to the right page, if the answer is in there and I just missed it.)You should not need to do anything special to make package functions visible, as long as they would be visible to a normal user. (Functions not exported in the NAMESPACE file won't be visible in the examples.) Are you sure you have a function with that exact name? It could be a typo somewhere, e.g. RandomEffectTree or RandomeffectsTree. Duncan Murdoch
Rebecca Sela
2009-May-16 16:58 UTC
[R] Checking a (new) package - examples require other package functions
After adding the right functions to the NAMESPACE file, I am now getting a different error: Error: package/namespace load failed for 'REEMtree' Call sequence: 2: stop(gettextf("package/namespace load failed for '%s'", libraryPkgName(package)), call. = FALSE, domain = NA) 1: library(package, lib.loc = lib.loc, character.only = TRUE, verbose = FALSE) Execution halted I have attached the NAMESPACE file in case that is where the problem is. Thanks again for your help! Rebecca ----- Original Message ----- From: "Duncan Murdoch" <murdoch at stats.uwo.ca> To: "Rebecca Sela" <rsela at stern.nyu.edu> Cc: "r-help" <r-help at r-project.org> Sent: Thursday, May 14, 2009 6:57:21 AM GMT -05:00 US/Canada Eastern Subject: Re: [R] Checking a (new) package - examples require other package functions On 13/05/2009 2:38 PM, Rebecca Sela wrote:> I am creating an R package. I ran R CMD check on the package, and everything passed until it tried to run the examples. Then, the result was: > > * checking examples ... ERROR > Running examples in REEMtree-Ex.R failed. > The error most likely occurred in: > >> ### * AutoCorrelationLRtest >> >> flush(stderr()); flush(stdout()) >> >> ### Name: AutoCorrelationLRtest >> ### Title: Test for autocorrelation in the residuals of a RE-EM tree >> ### Aliases: AutoCorrelationLRtest >> ### Keywords: htest tree models >> >> ### ** Examples >> >> # Estimation without autocorrelation >> simpleEMresult<-RandomEffectsTree(Y~D+t+X, data=simpleREEMdata, random=~1|ID, simpleREEMdata$ID) > Error: couldn't find function "RandomEffectsTree" > Execution halted > > > The function "RandomEffectsTree" is defined in the R code for the package. How can I refer to other functions from the package in examples? (I have the "Writing R-extensions" PDF, so it would be enough to point me to the right page, if the answer is in there and I just missed it.)You should not need to do anything special to make package functions visible, as long as they would be visible to a normal user. (Functions not exported in the NAMESPACE file won't be visible in the examples.) Are you sure you have a function with that exact name? It could be a typo somewhere, e.g. RandomEffectTree or RandomeffectsTree. Duncan Murdoch