darunabas/phyloregion

An error in phyloregion() function

Opened this issue · 2 comments

Hello,
It came an error when I was using phyloregion() function to visualize my output of phyloregion. I firstly choose rast2comm() to get a sparse matrix with my SDM rasters which only contains 0 and 1. Then, I turned the raster into a polygon using as.polygons() from terra package. When I put this polygon as an arguement of phyloregion(), an error said "Error in if (j[1] == "") { : missing value where TRUE/FALSE needed". So I checked my rasters and polygons with is.na(), and there' s nothing wrong with them. It really confused me.
I hope you will see my question and I' ll be grateful for solving this problem for me.
Best regards.

Could you share a reproducible example? Ideally, you should be able to join the raster cell ids with the ids from the sparse matrix to visualize in geographic space. Please share an example of the issue?

Example.zip
Thank you for helping me solve this problem!
I update 3 files which is my scripts, the data I calculated by phyloregion package and the rasters of whole taxa for the vector of polygons. I have seen some scripts form others that used " shp" arguement instead of " pol" in phyloregion() function, so I tried this morning and it worked. But when I want to plot it, it was said I should put a vector of polygon and it failed again when I use my polygon.
I tried to join the grid cells id in the rasterdata, but I found the id from sparse matrix is extrremely lower than the cells from raster. I don't know how to deal with it.
Thanks again for helping me!
Best regards.