A_05_Predictors_avonet.R

A - 05: Prepare AVONET predictors

Source 00_Configuration.R

Code
source(here::here("Code/00_Configuration.R"))
x <- lapply(package_list, require, character = TRUE)
sf_use_s2(TRUE)
rm(x)


tax_path <-
  here("Data/input/Tax_lookup.csv")

Load data & avonet

Code
sci_name <-
  readRDS(here::here("Data/output/1_data_filtered.rds")) %>%
  distinct(verbatimIdentification, scientificName) # BirdLife 2024 taxonomy

Tax <- read.csv(tax_path)

traits <-
  read_excel(here::here("Data/input/AVONET Supplementary dataset 1.xlsx"),
              sheet = "AVONET1_BirdLife")  %>%
  dplyr::select(
    Species1, Mass,
    Habitat, Migration, Primary.Lifestyle) %>%
  mutate(
    across(c(Habitat, Migration, Primary.Lifestyle),
           as.factor))

traits_merged <- traits %>%
  rename("ScientificName2018" = "Species1") %>%
  right_join(Tax %>%
               select(verbatimIdentification, scientificName, ScientificName2018)) %>%
  select(-ScientificName2018)

traits_merged %>% skimr::skim()
Data summary
Name Piped data
Number of rows 890
Number of columns 6
_______________________
Column type frequency:
character 2
factor 3
numeric 1
________________________
Group variables None

Variable type: character

skim_variable n_missing complete_rate min max empty n_unique whitespace
verbatimIdentification 0 1 9 32 0 762 0
scientificName 0 1 9 39 0 726 0

Variable type: factor

skim_variable n_missing complete_rate ordered n_unique top_counts
Habitat 9 0.99 FALSE 11 For: 263, Wet: 171, Gra: 110, Shr: 84
Migration 9 0.99 FALSE 3 3: 486, 1: 202, 2: 193, NA: 0
Primary.Lifestyle 9 0.99 FALSE 5 Ins: 318, Ter: 252, Gen: 130, Aer: 103

Variable type: numeric

skim_variable n_missing complete_rate mean sd p0 p25 p50 p75 p100 hist
Mass 9 0.99 412.26 1066.86 3.09 19.44 65.49 339.63 10682.04 ▇▁▁▁▁

Save to .rds

Code
#| eval: false
saveRDS(traits_merged, here::here("Data/output/A_predictors/Avonet.rds"))