BiologicalRecordsCentre / wrappeR

0 stars 10 forks source link

Species number is zero for year 1 in output from calcMSI #28

Open 03rcooke opened 3 years ago

03rcooke commented 3 years ago

calcMSI returns a Summary dataframe with indicator, lower, upper, year, and Species_Number. Species_Number returns zero for year 1. For instance, for 2020_bwars Ants it returns 0 for year 1 and 35 for all other years.

03rcooke commented 3 years ago

I think this behaviour only occurs under the "lambda" method

drnickisaac commented 3 years ago

It's not strictly an error. The number of species is calculated from the number of growth rates that contribute in any one year. Since the growth rate in year t is based on the change in occupancy since t-1, there is no growth rate information for t=1. However, I agree this is confusing. My suggested fix is to change the code in lambda method to return NA rather than zero, and include a note in the documentation explaining the above. A quick look at the code (lambda_indicator.r in BRCindicators) reveals that NAs are removed on line 169. Removing this line would solve this issue but would likely create others. So a little more digging is required.