search for: funwork

Displaying 2 results from an estimated 2 matches for "funwork".

Did you mean: funworks
2023 May 25
4
environments: functions within functions
...roach be for the package authors? library(mixR) # first example from ?mixfit ## fitting the normal mixture models set.seed(103) x <- rmixnormal(200, c(0.3, 0.7), c(2, 5), c(1, 1)) data <- bin(x, seq(-1, 8, 0.25)) fit1 <- mixfit(x, ncomp = 2) # raw data rm(x, data) ### # simple function funworks <- function(x) { print(x) } ### # almost identical simple function funfails <- function(thisx) { print(thisx) } ### funworks(fit1) funfails(fit1) ####### The explanation as I understand it... print called on this object gets passed to print.mixfitEM(), which is: function (x,...
2023 May 25
1
environments: functions within functions
...ly) > mc[[1]] <- as.name(fun.name) > eval(mc, environment()) > } > > > Working through the calls, when eval() is called from within > funfails(), mc is printnormal(x = thisx, digits = 7) > and the calling environment does not contain thisx. Your functions, both funworks and funfails, did nothing wrong. They are using R as intended, so there shouldn't be anything to fix. I think that mixR::mixfitEM is making a mistake in its use of non-standard evaluation. When working with match.call(), the typical pattern is to eval() the modified call in the parent.frame()...