R/find_taxa.R
find_taxa.Rdfind_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_"
)Character. Taxa name to find.
Character. Name of column(s) across data frames containing taxa information.
Dataframe with column names matching taxa_cols, usually,
say, taxonomy$species$lutaxa as a result of make_taxonomy().
Character. Prefix used in each of the data frames created at each step in the filtering process.
# 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)`
#> Error in check_pour_interactive(.slot): No data stored by `potions`
#> ℹ try using `brew()
# bin taxa
flor_taxa <- flor_recent %>%
bin_taxa(taxonomy = taxa$species)
#> Error: object 'taxa' not found
# distinct over bins
flor_bin <- flor_taxa %>%
dplyr::distinct(taxa, dplyr::across(tidyselect::any_of(context)))
#> Error: object 'flor_taxa' not found
# How did records of 'taxa' change through the filtering?
# Eucalyptus gracilis
find_taxa("Eucalyptus gracilis"
, lutaxa = taxa$species$lutaxa
)
#> Error: object 'taxa' not found
# Chenopodium nutans
find_taxa("Chenopodium nutans"
, lutaxa = taxa$species$lutaxa
)
#> Error: object 'taxa' not found