BiologicalRecordsCentre / sparta

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

occurrenceChange and region not specified error #71

Closed jonathoncharles123 closed 6 years ago

jonathoncharles123 commented 6 years ago

Hi, I'm trying to use the occurrenceChange function to calculate the percentdif change from the results of a "ranwalk","halfcauchy","catlistlength" occupancy model. Even though I have not specified a region, I get it an error message telling me 'region must be a character string identifying the regional estimates that change is to be calculated for.' Writing 'region=NULL' in the occDetFunc doesn't seem to help.

I'd be grateful if anyone could help with this issue!

Many thanks,

Jon Dunn

AugustT commented 6 years ago

@CharlieOuthwaite can you take a look at this. The error comes from the checks you added which do not account for when region is null. points the finger of blame ;)

I can fix this when I'm back in the office on Thursday or Friday if you can't get to it.

@jonathoncharles123 if you are happy making changes yourself you can put in a pull request, else we will fix this in the next couple of days

jonathoncharles123 commented 6 years ago

If OK with you, I'd prefer if you guys made the changes (I wouldn't want to unintentionally mess anything up).

Happy to test it again in a couple of days!

AugustT commented 6 years ago

@jonathoncharles123 I have put in afix just now, can you test

@CharlieOuthwaite I made a direct change to the master here on github. cheeky but it was an easy fix

CharlieOuthwaite commented 6 years ago

Nice one, thanks for sorting that!

jonathoncharles123 commented 6 years ago

Thanks, Tom. I can confirm the function now works even when region is not specified. Unfortunately this seems to have raised another issue! When I specify change as 'difference' or 'percentdif', the firstYear and lastYear arguments do not seem to affect the mean value given. 'growthrate' and 'lineargrowth' seem to work fine. i.e. the give different value when firstYear and lastYear are changed.

CharlieOuthwaite commented 6 years ago

Clearly I didn't do a very good job of testing these new additions to the function! Sorry guys, I will look into this today.

AugustT commented 6 years ago

@jonathoncharles123 Charlie has put in a fix for this now, can you give it a test and make sure it is working for you?

jonathoncharles123 commented 6 years ago

Thanks Charlie and Tom - I've given it a test and can confirm it now works as it should!