find_taxa does not work hierarchically. For example Eucalyptus will only match genus level records, not species records, such as Eucalyptus leucoxylon.

find_taxa(
  taxa_to_find,
  taxa_cols = c("original_name", "taxa"),
  lutaxa,
  filt_df_prefix = "flor_"
)

Arguments

taxa_to_find

Character. Taxa name to find.

taxa_cols

Character. Name of column(s) across data frames containing taxa information.

lutaxa

Dataframe with column names matching taxa_cols, usually, say, taxonomy$species$lutaxa as a result of make_taxonomy().

filt_df_prefix

Character. Prefix used in each of the data frames created at each step in the filtering process.

Examples



# library(envClean)

# Example taxa
use_taxa <- "Eucalyptus gracilis"

# Set context
context <- c("lat", "long", "month", "year")

# Start
flor_start <- flor_all %>%
  tibble::as_tibble() %>%
  envFunc::add_time_stamp()

# Remove singletons
flor_single <- flor_start %>%
  filter_counts(context = context
                , thresh = 5
                ) %>%
  envFunc::add_time_stamp()

# Just keep most recent contexts
flor_recent <- flor_single %>%
  dplyr::group_by(across(any_of(context[!context %in% c("month", "year")]))) %>%
  dplyr::filter(year == max(year)
                , month == max(month)
                ) %>%
  dplyr::ungroup() %>%
  envFunc::add_time_stamp()

# make_taxonomy
taxa <- make_taxonomy(df = flor_recent)
#> Joining with `by = join_by(original_name)`
#> Querying API ■■                                 5% |  ETA: 20s
#> Querying API ■■■                                6% |  ETA: 18s
#> Querying API ■■■                                8% |  ETA: 18s
#> Querying API ■■■■                               9% |  ETA: 17s
#> Querying API ■■■■                              11% |  ETA: 16s
#> Querying API ■■■■■                             12% |  ETA: 15s
#> Querying API ■■■■■                             14% |  ETA: 15s
#> Querying API ■■■■■                             15% |  ETA: 14s
#> Querying API ■■■■■■                            16% |  ETA: 14s
#> Querying API ■■■■■■                            18% |  ETA: 13s
#> Querying API ■■■■■■■                           19% |  ETA: 13s
#> Querying API ■■■■■■■                           20% |  ETA: 13s
#> Querying API ■■■■■■■■                          22% |  ETA: 13s
#> Querying API ■■■■■■■■                          23% |  ETA: 12s
#> Querying API ■■■■■■■■                          25% |  ETA: 12s
#> Querying API ■■■■■■■■■                         26% |  ETA: 12s
#> Querying API ■■■■■■■■■                         28% |  ETA: 11s
#> Querying API ■■■■■■■■■■                        29% |  ETA: 11s
#> Querying API ■■■■■■■■■■                        30% |  ETA: 11s
#> Querying API ■■■■■■■■■■■                       32% |  ETA: 11s
#> Querying API ■■■■■■■■■■■                       33% |  ETA: 10s
#> Querying API ■■■■■■■■■■■                       35% |  ETA: 10s
#> Querying API ■■■■■■■■■■■■                      36% |  ETA: 10s
#> Querying API ■■■■■■■■■■■■                      38% |  ETA:  9s
#> Querying API ■■■■■■■■■■■■■                     40% |  ETA:  9s
#> Querying API ■■■■■■■■■■■■■                     41% |  ETA:  9s
#> Querying API ■■■■■■■■■■■■■■                    43% |  ETA:  9s
#> Querying API ■■■■■■■■■■■■■■                    44% |  ETA:  8s
#> Querying API ■■■■■■■■■■■■■■■                   46% |  ETA:  8s
#> Querying API ■■■■■■■■■■■■■■■                   47% |  ETA:  8s
#> Querying API ■■■■■■■■■■■■■■■■                  49% |  ETA:  8s
#> Querying API ■■■■■■■■■■■■■■■■                  50% |  ETA:  7s
#> Querying API ■■■■■■■■■■■■■■■■■                 52% |  ETA:  7s
#> Querying API ■■■■■■■■■■■■■■■■■                 53% |  ETA:  7s
#> Querying API ■■■■■■■■■■■■■■■■■                 55% |  ETA:  7s
#> Querying API ■■■■■■■■■■■■■■■■■■                56% |  ETA:  6s
#> Querying API ■■■■■■■■■■■■■■■■■■                57% |  ETA:  6s
#> Querying API ■■■■■■■■■■■■■■■■■■■               59% |  ETA:  6s
#> Querying API ■■■■■■■■■■■■■■■■■■■               61% |  ETA:  6s
#> Querying API ■■■■■■■■■■■■■■■■■■■■              62% |  ETA:  6s
#> Querying API ■■■■■■■■■■■■■■■■■■■■              64% |  ETA:  5s
#> Querying API ■■■■■■■■■■■■■■■■■■■■              65% |  ETA:  5s
#> Querying API ■■■■■■■■■■■■■■■■■■■■■             66% |  ETA:  5s
#> Querying API ■■■■■■■■■■■■■■■■■■■■■             68% |  ETA:  5s
#> Querying API ■■■■■■■■■■■■■■■■■■■■■■            70% |  ETA:  4s
#> Querying API ■■■■■■■■■■■■■■■■■■■■■■            71% |  ETA:  4s
#> Querying API ■■■■■■■■■■■■■■■■■■■■■■■           72% |  ETA:  4s
#> Querying API ■■■■■■■■■■■■■■■■■■■■■■■           73% |  ETA:  4s
#> Querying API ■■■■■■■■■■■■■■■■■■■■■■■           74% |  ETA:  4s
#> Querying API ■■■■■■■■■■■■■■■■■■■■■■■■          75% |  ETA:  4s
#> Querying API ■■■■■■■■■■■■■■■■■■■■■■■■          77% |  ETA:  3s
#> Querying API ■■■■■■■■■■■■■■■■■■■■■■■■          78% |  ETA:  3s
#> Querying API ■■■■■■■■■■■■■■■■■■■■■■■■■         80% |  ETA:  3s
#> Querying API ■■■■■■■■■■■■■■■■■■■■■■■■■         81% |  ETA:  3s
#> Querying API ■■■■■■■■■■■■■■■■■■■■■■■■■■        83% |  ETA:  2s
#> Querying API ■■■■■■■■■■■■■■■■■■■■■■■■■■        84% |  ETA:  2s
#> Querying API ■■■■■■■■■■■■■■■■■■■■■■■■■■■       86% |  ETA:  2s
#> Querying API ■■■■■■■■■■■■■■■■■■■■■■■■■■■       88% |  ETA:  2s
#> Querying API ■■■■■■■■■■■■■■■■■■■■■■■■■■■■      89% |  ETA:  2s
#> Querying API ■■■■■■■■■■■■■■■■■■■■■■■■■■■■      91% |  ETA:  1s
#> Querying API ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■     92% |  ETA:  1s
#> Querying API ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■     93% |  ETA:  1s
#> Querying API ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■    95% |  ETA:  1s
#> Querying API ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■    97% |  ETA:  0s
#> Querying API ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■    98% |  ETA:  0s
#> Querying API ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■  100% |  ETA:  0s
#> Matched 264 of 265 taxonomic search terms in selected atlas (Australia).
#> 1 unmatched search term:
#>  "Kali tragus"
#> 
#> Joining with `by = join_by(original_name)`
#> Joining with `by = join_by(original_name)`
#> saving results to C:/temp/nige\RtmpEBQxW6\file34d833b16246.parquet
#> The following were completely unmatched: Kali tragus. Consider providing more taxonomic levels, or an override, for each unmatched taxa?
#> Joining with `by = join_by(original_name)`
#> Joining with `by = join_by(original_name)`

# bin taxa
flor_taxa <- flor_recent %>%
  bin_taxa(taxonomy = taxa$species)
#> Joining with `by = join_by(original_name)`
#> Joining with `by = join_by(taxa)`
#> Joining with `by = join_by(original_name)`

# distinct over bins
flor_bin <- flor_taxa %>%
  dplyr::distinct(taxa, dplyr::across(tidyselect::any_of(context)))

# How did records of 'taxa' change through the filtering?
# Eucalyptus gracilis
find_taxa("Eucalyptus gracilis"
          , lutaxa = taxa$species$lutaxa
          )
#> # A tibble: 0 × 9
#> # ℹ 9 variables: name <chr>, obj <list>, has_stamp <lgl>, nrow <dbl>,
#> #   ctime <???>, founds <list>, taxa <chr>, records <dbl>, found <chr>

# Chenopodium nutans
find_taxa("Chenopodium nutans"
          , lutaxa = taxa$species$lutaxa
          )
#> # A tibble: 0 × 9
#> # ℹ 9 variables: name <chr>, obj <list>, has_stamp <lgl>, nrow <dbl>,
#> #   ctime <???>, founds <list>, taxa <chr>, records <dbl>, found <chr>