В Sun, 15 Sep 2024 00:43:31 +0000
"Therneau, Terry M., Ph.D. via R-devel" <r-devel@r-project.org> пишет:

>   2.  Before calling model.frame(), insert my copy of strata into the
> calling chain coxenv <- new.env(parent= environment(formula))
>     assign("strata", survival::strata, envir= coxenv)
>     environment(formula) <- coxenv

<...>

> For ultimate safety, I am thinking of extending the above to all of
> the internal survival functions that might be used in a formula:
> Surv, strata, pspline, cluster, ratetable  (I think that_s all).   An
> intitial limited test looks okay, but before anything migrates to
> CRAN I am looking for any feedback.

What do you think of the following approach?

When changing the environment of the formula, construct the following
environment chain:

1. Top: your 'coxenv' environment with the special survival functions
2. Enclosing environment: list2env(data)
3. Enclosing^2 environment: original environment(formula)

Since the environment chain constructed by eval() when called by
model.frame() looks different (top: data -> enclosure:
environment(formula)), someone truly determined to shoot themselves in
the foot could still sneak a 'strata' function inside their 'data'
argument.

Having said that, what you are planning to implement may be already
reliable enough.

-- 
Best regards,
Ivan

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to