Open see24 opened 9 months ago
wt_replace_tmtt and wt_make_wide are removing sites with 0 birds despite calling wt_tidy_species with zerofill = TRUE
wt_replace_tmtt
wt_make_wide
wt_tidy_species
zerofill = TRUE
library(wildRtrax) library(testthat) library(dplyr) # Download report to use for testing Sys.setenv(WT_USERNAME = "guest", WT_PASSWORD = "Apple123") wt_auth(force = TRUE) #> Authentication into WildTrax successful. ecosys21 <- wt_download_report(685, 'ARU', 'main', FALSE) # add a location with 0 birds observed ecosys21_mod_row <- slice(ecosys21, 1) ecosys21_mod_row$species_code <- "MOBA" ecosys21_mod_row$species_scientific_name <- NA ecosys21_mod_row$vocalization <- "Non-vocal" ecosys21_mod_row$location_id <- ecosys21_mod_row$location_id+max(ecosys21$location_id) ecosys21_mod <- bind_rows(ecosys21, ecosys21_mod_row) # all locations from input should be present in outputs unless not transcribed ecosys21_locs <- ecosys21_mod %>% filter(aru_task_status == "Transcribed") %>% distinct(location_id) ecosys21_tidy <- wt_tidy_species(ecosys21_mod, remove = c("mammals", "abiotic", "amphibians"), zerofill = T, "ARU") #> Successfully downloaded the species table! ecosys21_locs %>% anti_join(ecosys21_tidy, by = "location_id") %>% pull(location_id) %>% expect_length(0) ecosys21_tmtt <- wt_replace_tmtt(ecosys21_tidy, calc = "round") ecosys21_locs %>% anti_join(ecosys21_tmtt, by = "location_id") %>% pull(location_id) %>% expect_length(0) #> Error: `.` has length 1, not length 0. ecosys21_wide <- wt_make_wide(ecosys21_tmtt, sound = "all", sensor = 'ARU') ecosys21_locs %>% anti_join(ecosys21_wide, by = "location_id") %>% pull(location_id) %>% expect_length(0) #> Error: `.` has length 1, not length 0. # total abundance should be 0 filter(ecosys21_wide, location_id == ecosys21_mod_row$location_id) %>% rowwise() %>% mutate(tot_birds = sum(c_across(matches("^....$")))) %>% pull(tot_birds) %>% expect_equal(0) #> Error: `.` not equal to 0. #> Lengths differ: 0 is not 1
Created on 2024-01-31 with reprex v2.0.2
The code above will only run on my branch due to an issue with wt_tidy_species
wt_replace_tmtt
andwt_make_wide
are removing sites with 0 birds despite callingwt_tidy_species
withzerofill = TRUE
Created on 2024-01-31 with reprex v2.0.2