bioXgeo / geodiv

Other
11 stars 2 forks source link

Error in Sa calculation #8

Closed skallagrimmson closed 2 years ago

skallagrimmson commented 2 years ago

@AnnieCooper

I think there is an error in the calculation of Sa, which only plays a role in rasters with a lot of NA values.

zbar <- mean(z, na.rm = TRUE)
  N <- length(z)

  val <- sum(abs(z - zbar), na.rm = TRUE) / N

while mean() excludes na's, length() does include all items in the list, including na's (as far as I know).

Best wishes,

Eduard

edit: also in Ssk and Sku

adammwilson commented 2 years ago

Thanks for reporting this. I agree it's an error and I've corrected it in the development branch. You can install this corrected version with devtools::install_github("bioXgeo/geodiv",ref = "dev")

AnnieCooper commented 2 years ago

Thanks Eduard for reporting this, and Adam for correcting the error on the development branch. I have merged the changes made in the dev branch and fixed the errors in Ssk and Sku as well. The package version on CRAN is now updated with these changes.