Are you sure the R versions are compatible here?
The internal parts of ecdf()
and approxfun()
objects {yes, they are functions} have been changed relatively recently and now go via the .approxfun(..)
wrapper which is a hidden in the "stats" namespace.
But I really assume the problem comes because you use data(.) in order to use such objects in your package,
and on R package building, R may resave the data and ends up losing the important property
that environment(fc)
must have "stats"
as a parent environment.
> set.seed(7); Fn <- ecdf(rnorm(12))
> save(Fn, file="/tmp/Fn.rda")
> rm(Fn)
> load(file="/tmp/Fn.rda")
> Fn
Empirical CDF
Call: ecdf(rnorm(12))
x[1:12] = -1.1968, -0.97067, -0.94728, ..., 2.2872, 2.7168
> plot(Fn)
> Fn(1)
[1] 0.75
> q()
... restart R
> (load(file="/tmp/Fn.rda"))
[1] "Fn"
> Fn(1)
[1] 0.75
> parent.env(environment(Fn))
<environment: namespace:stats>
So everything works with regular save()ing and load()ing of ecdf objects.
Solution proposal: Don't use data()
for storing objects that are used inside your functions.
data()
is not at all thought for this (but rather for providing illuminating data sets).
Rather put it into something like /inst/internal/ecdf_lst.rda
and get it into your function by something like
load(system.file("internal/ecdf_lst.rda", package="<pkg>"))