I wanted to use mselec function from drc package for selecting the best model of a dose-response dataset. However, mselect does not work if you use it inside a function.
The following code works:
library(drc)
ryegrass.m1 <- drm(rootl~conc, data = ryegrass, fct = LL.4())
mselect(ryegrass.m1,list(LL.5(), LN.4(), W1.4(), W2.4()))
But not this one:
best.fit=function(data){
model1=drm(rootl~conc, data=data, fct=LL.4())
M1=drc::mselect(model1, list(LL.5(), LN.4(), W1.4(), W2.4()))
return(M1)
}
best.fit(ryegrass)
I think the problem is related with the environments in R, but I don't know how to fix it. Someone could help me please?