get_indicatorNe_data_BG <- function (kobo_output = kobo_output)
     {
         kobo_output <- kobo_output


         # pivot_longer() requires values in columns to be the same class
         kobo_output <- kobo_output %>% 
             mutate(across(starts_with("IntroductionYear"),
             as.character)) %>% mutate(across(starts_with("NeYear"),
             as.character)) %>% mutate(across(starts_with("NcYear"),
             as.character)) %>% mutate(across(starts_with("NcRangeDetails"),
             as.character)) %>% 
           
           # select relevant columns
           dplyr::select(X_uuid, taxonomic_group, taxon,
                         
             defined_populations, time_populations, n_extant_populations,
             popsize_data, ne_pops_exists, nc_pops_exists, ratio_exists,
             species_related, ratio_species_related, ratio_formatted, ratio_year, source_popsize_ratios,
             
             Name_pop1:Comments_pop25, ) %>% 
           
           # place populations in separate rows
           pivot_longer(cols = matches("_pop[0-9]"),
             names_to = c(".value", "population"), names_sep = "_",
             values_drop_na = TRUE) %>% # this discards observation where you don't have any population information
           
           # convert empty spaces to NA
           mutate(across(everything(),
             ~{
                 if (is.character(.) || is.factor(.)) {
                    na_if(as.character(.), "")
                 }
                 else {
                     .
                 }
             })) %>% 
           
           # convert -999 to NA
           mutate(Ne = na_if(Ne, -999), NeLower = na_if(NeLower,
             -999), NeUpper = na_if(NeUpper, -999), NcPoint = na_if(NcPoint,
             -999), NcLower = na_if(NcLower, -999), NcUpper = na_if(NcUpper,
             -999)) %>% 
           
           # remove columns entirely composed of NAs
           remove_empty(which = "cols", cutoff = 1, quiet = F)
}
