BiologicalRecordsCentre / sparta

Species Presence/Absence R Trends Analyses
http://biologicalrecordscentre.github.io/sparta/index.html
MIT License
21 stars 24 forks source link

Region identifiers are `length(nvisit)` but should be `length(nsite)` #221

Closed drnickisaac closed 3 years ago

drnickisaac commented 3 years ago

Region identifiers are length(nvisit) but should be length(nsite) This has crept into occDetFunc in the most recent version (0.2.11-0.2.12). I am fixing it now. It means that region-level occupancy results cannot be trusted.

drnickisaac commented 3 years ago

Problem is here: https://github.com/BiologicalRecordsCentre/sparta/blob/6c8c993887523545cb13f6f878d0e7c70f149a6a/R/occDetFunc.r#L473 nrow(occDetdata) = nvisit

AugustT commented 3 years ago

This is a BIG issue?! I guess all recent model runs will need to re-run?

AugustT commented 3 years ago

@mlogie

drnickisaac commented 3 years ago

If affects the most recent Mayflies and the tail end of the Caddis run last week.

drnickisaac commented 3 years ago

ok, fixed it First: regional_codes <- merge(regional_codes, site_match, by.y="name", by.x="site") then bugs_data[paste0('r_', region)] <- list(regional_codes[order(regional_codes$id), region])

AugustT commented 3 years ago

Can you do a PR then we can kick the models off again

drnickisaac commented 3 years ago

Yup. I am running the Tests locally now.

drnickisaac commented 3 years ago

Fixed some fails introduced by other tinkering (to be documented in PR). Now ready to go. This issue can be closed once the PR is accepted (I forget how to do this).

AJacksonMCS commented 3 years ago

This is interesting to read. I had some problems with regional outputs at the end of last week - for some regions (but not others) I was getting only zeros in psi.fs.r* - these regions had worked fine previously. Might this be related?

AugustT commented 3 years ago

Could be. Do you know what version you were using? This bug effected .11 and .12

AJacksonMCS commented 3 years ago

Hey Tom - not sure. I'm a bit of a Github newby - where can I find the version # ? (I'm sure it is somewhere obvious, but can't find it). After a few snags with the testthat package in devtools, I have just reinstalled Sparta and trying again with the regions.

AugustT commented 3 years ago

sessionInfo() will print out the packages you have loaded and their versions

AJacksonMCS commented 3 years ago

Thanks Tom. I ran everything last night with .14 and it all worked smoothly.

AugustT commented 3 years ago

Fantastic, sorry if our bug got in your way!