PhilipMostert / PointedSDMs

Wrapper function for 'inlabru' for modeling species distribution models from disparate datasets.
23 stars 5 forks source link

Syntactic error in if(...) {...} else {...} code in bruSDM_predict #13

Closed RRTogunov closed 5 months ago

RRTogunov commented 5 months ago

Line comment: https://github.com/PhilipMostert/PointedSDMs/commit/23d50672db08dcf347ae3111b1eee89ee12f0b9f#r141274248

I think all the "else" statements in bruSDM_predict.R should all be on the previous line. At least on my system/R version, I cannot have a line of code start with an else. For example, the theoretical code

if(FALSE) {"Yes"}
else {"No"}

returns Error: unexpected 'else' in " else". instead, it would have to be

if(FALSE) {
   "Yes"
} else {
    "No"
}

I get that error on Line 118, which should be } else {. similarly, line 126 should be

if (is.null(species)) {
    speciesin <- unique(unlist(object[['species']][['speciesIn']]))
} else {
    speciesin <- species`
}

This seems to be an issue with every instance of else in this file.

RRTogunov commented 5 months ago

Update: Turns out, when its only an issue (i.e., returns unexpected 'else' in " else" error) when executing the code in debugging/browser mode, but it's fine when run as a function, so feel free to delete this since it's a stylistic choice.

PhilipMostert commented 5 months ago

Thanks for checking this. Maybe not the best coding practices, but maybe I'll keep it as is if it works.