Open JonasBeal opened 5 years ago
I seem to be having the same problem trying to run neWeight()
within purrr:pmap()
to examine different mediator model settings. I have a nested tibble with each row containing a formula, data tibble, and model fit. I wanted to run neWeight()
in each row. The same data object not found error was encountered.
It seems to stem from the discrepancy of the environment the model formula was defined and the environment in which the dataset resides. I'll try to resolve this.
eval(args$data, environment(stats::formula(fit)))
Dear medflex authors,
Thanks for this very convenient package. I have some problems when I try to use medflex functions within another function. This seems to me to be related to scoping problems, perhaps related to issues 6 or 14. However, the answers to these issues did not allow me to solve my problem satisfactorily. Here are examples.
1) Not working example
Last command results in :
Please note that naming my
dta
variabledata
as suggested in issue 14 for xFit seems to circumvent the problem but result in a new one2) Without function
If I remove the functional form it works fine:
3) Force global variable
By the way, if I force my function/local variable to be global, putting the following code at the beginning of my function in 1), it works but it seems a little unsatisfactory
Thanks a lot for your insights and your time