kosukeimai / mediation

R package mediation
58 stars 29 forks source link

Error in eval(extras, data, env) : object 'Call.M' not found #30

Closed LeoSokolovic closed 2 years ago

LeoSokolovic commented 3 years ago

Hi,

I just re-ran an old analysis which functioned without problems in November 2020 but returns this error now Error in eval(extras, data, env) : object 'Call.M' not found.

I did not change the code at all.

I already tried reinstalling the package, but that didn't help.

Could you help me with this issue?

Best regards Leo

eweisbrod commented 2 years ago

Hi I have the same issue. I just updated my R from 4.0.3 to 4.1.1

eweisbrod commented 2 years ago

I think I narrowed this down to the "use_speed" option. When I remove that option, my code works. I also think it might be related to a couple lines in the mediate.R code where you write lowercase "call.m" instead of "Call.M":

it's line 519 when I view the code on github: call.m <- getCall(model.m) call.y <- getCall(model.y)

call.m$data <- call.y$data <- newdata
if(c("(weights)") %in% names(newdata)){
  call.m$weights <- call.y$weights <- model.weights(newdata)
}
model.m <- eval.parent(call.m)
model.y <- eval.parent(call.y)
if(!is.null(cluster)){
  cluster <- factor(newdata[, ncol(newdata)])  # factor drops missing levels
}

}

kosukeimai commented 2 years ago

@eweisbrod Thanks for this. I've fixed the issue.