1

I'm using R to analyze a linear mixed effects model (nlme::lme). I want to plot the ACF values with a dashed line at the alpha level (as plot.ACF does).

After I require(nlme), I can run ACF, but plot.ACF is still not available. I can access it via nlme:::plot.ACF though, meaning it's designated as a hidden function. Was this feature of the package shelved for some reason? If not, is there another likely explanation? Does anyone know a way in which I can make the package export it (even after updating)?

2 Answers2

1

Yes, it is hidden from the front end of the nlme package (ie, not exported); I don't know if this is a change or not.

> nlme::plot.ACF
Error: 'plot.ACF' is not an exported object from 'namespace:nlme'

However, you can access the help for it using ?plot.ACF, where it demonstrates the following usage:

## S3 method for class 'ACF'
plot(x, alpha, xlab, ylab, grid, ...)

Note that it's not suggesting using plot.ACF but instead just plot. This works because the plot function is object-oriented, so will call plot.ACF behind the scenes whenever plot is called on an ACF object.

That is, to plot an ACF object you should just type plot, not plot.ACF.

Aaron left Stack Overflow
  • 36,704
  • 7
  • 77
  • 142
1

As far as I can tell, the plot.ACF function was never exported. The earliest version of nlme from https://cran.r-project.org/src/contrib/Archive/nlme/ that I could find with a NAMESPACE file was nlme_3.1-40 (Date: 2003-05-16), and that function would have been invisible (at the console). It still would have been accessible with the methods function and the code would have been available with the triple dot mechanism (:::) or getAnywhere functions.

getAnywhere("plot.ACF")  Retruns formal parameters, funciton body and information about functions environment
getS3method("plot", "ACF")  # returns same code as getAnywhere

x <- methods(class="ACF")
str(x)
#--------------
 'MethodsFunction' chr "plot.ACF"
 - attr(*, "info")='data.frame':    1 obs. of  4 variables:
  ..$ visible: logi FALSE
  ..$ from   : Factor w/ 1 level "registered S3method": 1
  ..$ generic: chr "plot"
  ..$ isS4   : logi FALSE
 - attr(*, "byclass")= logi TRUE

I apologize for my earlier, somewhat snarky comment, because on re-reading your post it appears you do understand that the functions is available, just not visible. What's still unclear is why you thought it was ever visible.

If you want to have plot.ACF exported, you could add it to the list of exported functions in the NAMESPACE file and rebuild the package. Or you could export on the fly with:

plot.ACF <- getAnywhere("plot.ACF")
IRTFM
  • 258,963
  • 21
  • 364
  • 487