babaknaimi / sdm

sdm is an extensible framework to develop species distributions models using individual and community-based approaches, generate ensembles of models, evaluate the models, and predict species potential distributions in space and time.
20 stars 5 forks source link

Can't add new method to modify model settings #15

Open mattmar opened 2 years ago

mattmar commented 2 years ago

Hello,

I've been trying to change the betamultiplier in the maxent settings with the function add() but without success. Here is my workflow:

maxent_dif <- sdm::getmethod('maxent','sdm')
maxent_dif@fitSettings$beta <- 5
sdm::add(x=maxent_dif, w='sdm')
Error in (function (classes, fdef, mtable)  : 
  unable to find an inherited method for function ‘add’ for signature ‘"sdmCorrelativeMethod", "character"’

Do you have any solution to this? Best wishes,

Matteo

babaknaimi commented 2 years ago

Hi,

Currently, the add function works only with a list. I will update it but meanwhile, you may use the following code:

maxent_dif <- sdm::getmethod('maxent','sdm')

maxent_dif@fitSettings$beta <- 5 maxent_dif@name <- "maxent_dif" maxent_dif@aliases <- "maxent2"

sdm:::.sdmMethods$addMethod(maxent_dif) # add the method

sdm::getmethodNames(alt=F) # check if it is added to the list of methods

Hope this helps,

Babak