NA samples in algorithms
Closed this issue · 0 comments
tgoodbody commented
VIA EMAIL FROM A USER:
I'm using an existing plot dataset that happens to have a column that is all NA's. Thus, when it gets to this part of extract_metrics all samples get flagged as having NA:
if (any(!complete.cases(samples))) {
nNA <- samples %>% dplyr::filter(!complete.cases(.)) %>%
dplyr::tally() %>% dplyr::pull()
message(paste0(nNA, " samples are located where metric values are NA."))
}
Instead of using complete.cases I think it needs to check only the columns that were added by terra::extract(mraster,xy). Otherwise, any NA's in the original existing plot sf object get flagged.
Maybe something like:
if (any(!complete.cases(samples %>% dplyr::select(one_of(names(vals)))))) {
nNA <- samples %>% dplyr::select(one_of(names(vals))) %>% dplyr::filter(!complete.cases(.)) %>%
dplyr::tally() %>% dplyr::pull()
message(paste0(nNA, " samples are located where metric values are NA."))
}