[R] environments: functions within functions

Ivan Krylov kry|ov@r00t @end|ng |rom gm@||@com
Thu May 25 18:10:32 CEST 2023


(Sorry for the double post.)

В Thu, 25 May 2023 18:53:45 +0300
Ivan Krylov <krylov.r00t using gmail.com> пишет:

> print(fit1) # tracer not called

Interesting. There must be some caching involved. If print(a) is
resolved to print.mixfitEM at least once, it keeps failing. In a fresh
R session, where a trace()-patch is done before printing objects of
this class, print(a) succeeds:

trace(mixR:::print.mixfitEM, quote({ mc$x <- x }), at = 7)
(function(a) print(a))(fit1) # this used to fail
# Tracing print.mixfitEM(a) step 7
# Normal mixture model with 2 components
#        comp1     comp2
# pi 0.2977772 0.7022228
# mu 2.0140197 4.9837052
# sd 0.8896020 1.0273591
# 
# EM iterations: 78 AIC: 759.35 BIC: 775.84 log-likelihood: -374.67

-- 
Best regards,
Ivan



More information about the R-help mailing list