RetoSchmucki / rbms

A home for the latest rbms R package
https://retoschmucki.github.io/rbms/
Other
4 stars 5 forks source link

Add functionality for regional collation #6

Closed RetoSchmucki closed 4 years ago

RetoSchmucki commented 4 years ago

Compute collation for regional subsets as requested by @dafneram

Dafneram commented 4 years ago

Thanks for helping out Reto,

I am trying to use our national data to calculate the flight curve and site indices and then select all the sites in a region before calculating the collated index per region. However, now the "if(nrow(sindex_sp)>0)" that use to filter out too scarce cases during the site index calculation, doesn't do this because I run these calculations on national data which is usually plenty.

There are cases where, after I make the regional selection from the site indices, there is only or mostly zeros left in the SINDEX column. So I would need to come up with a way to set a new if() statement to deal with the zeros. Or maybe make the region selection before calculating the site indices, but still after the flight curve. I hope this makes sense..

I have adapted the code to take in parameters so we can loop over them on unix, but for now I am just running tests in Rstudio with manually chosen parameters. (code currently has a species and region selected with too scarce data)

The code and data (originally .R and .csv files) are attached here as text files.

RBMS_2610.txt count_data.txt visit_data.txt

RetoSchmucki commented 4 years ago

@Dafneram @larspett I resolved the issue which was a bug in the collated_index function caused by the extra parenthesis in the formula related to the cases having only 1 site. This is now fixed and working in the rbms package. I updated your code to the rbms package, moving away from "D"evelopment version that is not maintained.

Your code and working example are available in this repository

Thank you for highlighting this bug!