occfilt_geo() only works with "x" and "y" columns
wevertonbio opened this issue · 1 comments
wevertonbio commented
Hi Santiago,
I found an error in the occfilt_geo() function. The function only works when the coordinate columns are named "x" and "y". If we run the function example, it works perfectly:
# Environmental variables
somevar <- system.file("external/somevar.tif", package = "flexsdm")
somevar <- terra::rast(somevar)
plot(somevar)
# Species occurrences
data("spp")
spp
spp1 <- spp %>% dplyr::filter(species == "sp1", pr_ab == 1)
somevar[[1]] %>% plot()
points(spp1 %>% select(x, y))
#Change column names
spp2 <- spp1 %>% dplyr::rename(longitude = x, latitude = y)
# Using Moran method
filtered_1 <- occfilt_geo(
data = spp,
x = "x",
y = "y",
env_layer = somevar,
method = c("moran"),
prj = crs(somevar)
)
However, when I rename the columns with the coordinates to "longitude" and "latitude," I get the following error:
#Change column names
spp2 <- spp1 %>% dplyr::rename(longitude = x, latitude = y)
# Using Moran method
filtered_1 <- occfilt_geo(
data = spp2,
x = "longitude",
y = "latitude",
env_layer = somevar,
method = c("moran"),
prj = crs(somevar)
)
Error in `[.data.frame`(da, c(x, y)) : colunas indefinidas selecionadas
sjevelazco commented
Hi @wevertonbio
Thank you so much for reporting this error. It was fixed. Please reinstall the package.
Best