0

I was looking at the R source codes for the zoo package (who many functions are extremely useful). I noticed a function .fill_short_gaps used quite a lot, but I can't find any documentation for this either in the zoo source codes or in the base source codes.

Is this an internal function? What is this function supposed to do?

uday
  • 6,453
  • 13
  • 56
  • 94

1 Answers1

0

It's an internal function. A checkin comment on version 661 of the source file says "Use base R coding style convention for internal non-exported functions: .fill_short_gaps() instead of fillShortGaps()."

I found the source on r-forge: http://r-forge.r-project.org/scm/viewvc.php/pkg/zoo/R/na.approx.R?view=markup&root=zoo

.fill_short_gaps() is at the bottom of that file.

Since the function was renamed recently, you should make sure that all of the libraries that you're using that reference it are using a compatible version of zoo.

shoover
  • 3,071
  • 1
  • 29
  • 40
  • 1
    It would probably be best to not use non-exported functions – Jake Burkhead Dec 20 '13 at 19:06
  • @JakeBurkhead, yeah, I meant to say that, too. But OP might be using some libraries that were using an old version of zoo that exported the function under its previous name. Maybe some insight into the motive behind OP's question is in order. Is OP just trying to understand how the library works, or is there a problem (e.g. R can't find the method)? – shoover Dec 20 '13 at 19:14
  • @JakeBurkhead, shoover, Yes, I'm trying to understand how the library works. E.g., I had read about the `rle()` and `inverse.rle()` functions in the R docs long time ago and at that time didn't think they would be really useful. The zoo package uses them so efficiently that many of their functions work very fast (compared to similar functions I often write). For example, I wanted to write an equivalent version of `na.locf` function with a very different treatment for `maxgap`. The `na.locf` function doesn't fill the gap if the gap is more than `maxgap`, whereas the treatment I wanted ... – uday Dec 20 '13 at 19:34
  • was to use `maxgap` to only fill up to the `maxgap`. For instance, if there is `NA` run of 5 `NA`(s) and `maxgap=3`, then the current treatment will not fill up the `NA`(s). I wanted to change it such that the first 3 `NA`(s) will be filled up and the remaining 2 won't be. I of course don't want to overwrite in the `zoo` package, but write my own function. – uday Dec 20 '13 at 19:36