"Error in file(con, "r") calling maxent function in R

hope someone can help me here. I am a ecologist and as part of my master degree's thesis I am making some species distribution using the maxent (https://www.cs.princeton.edu/~schapire/maxent/) function in R, with the Dismo package.

In a certain point of the script (exactilly the one with refers to the model itself) I am using the follow command line:

me<-maxent(predictors,spp.occ,args=c("-J","-P","replicates=10","replicatetype=crossvalidate"),path='Results')

And I get the following error message:

Error in file(con, "r") : cannot open the connection
In addition: Warning message:
In file(con, "r") :
cannot open file 'Results/species_9.lambdas': No such file or directory

After redoing the command several times exploring all its arguments I came to the conclusion that the argument that generates the error is the replicates = 10, which means that I want to replicate 10 times the template. I have perfomed with a smaller number of replications and up to 9 there was no error.

In advance I apologize for my language, in fact I am not a programmer, but I really need to resolve this issue and hope someone can help me.

Thank you very much.

The best,

Ramiro.

Upvotes: 2

Views: 637

Answers (1)

Michael L
Michael L

Reputation: 303

Hey just looping back to this because the comment above did not fix this issue for me: When the dismo::maxent function breaks, it will often throw this error instead of actually telling you what's wrong. Navigate to the path folder and find the "MaxEnt.log" file. Open that with notepad and that is the actual error message you're looking for.

The error message here is a bit inane as the ".lambdas" file is a temp file that the function is supposed to create itself. It can't find it because it never makes it because it has quietly broken in a previous step

Upvotes: 1

Related Questions