We are hiring ! See our job offers.
https://github.com/tom-n-walker/uphill-plants-soil-carbon
Raw File
Tip revision: a9e7a872d22a45dbd91bb00751d522812138eefd authored by Tom Walker on 08 February 2022, 15:18:56 UTC
Additional and revised analysis in response to author comments.
Tip revision: a9e7a87
clean_species_names.R
################################################################################
#### Project: Lowland plant migrations alpine soil C loss
#### Title:   Function | Clean species names
#### Author:  Tom Walker (thomas.walker@usys.ethz.ch)
#### Date:    26 May 2021
#### ---------------------------------------------------------------------------

clean_species_names <- function(formatted){
  # species names
  species <- unique(formatted$species)
  # call name resolver
  resolved <- gnr_resolve(species, 
                          best_match_only = T, 
                          with_canonical_ranks = T)
  # take resolved, select, join to data, merge gnr/original names, select
  cleaned <- resolved %>%
    select(user_supplied_name, accepted_name = matched_name2) %>%
    left_join(formatted, ., by = c("species" = "user_supplied_name")) %>%
    select(site, grid_id, species, accepted_name, total_cover)
  # deal with fuckers
  cleaned[cleaned$species == "bare ground", "accepted_name"] <- "bare ground"
  cleaned[cleaned$species == "Erigeron-Aster Group", "accepted_name"] <- "unknown"
  cleaned[cleaned$species == "Aster-Erigeron Group", "accepted_name"] <- "unknown"
  cleaned[cleaned$species == "Sebastian has photo_UKS", "accepted_name"] <- "unknown"
  cleaned[cleaned$species == "Grass Group", "accepted_name"] <- "unknown"
  cleaned[cleaned$species == "Lychen Group", "accepted_name"] <- "mosses"
  cleaned[cleaned$species == "Moos Group", "accepted_name"] <- "mosses"
  cleaned[cleaned$species == "CAREXLACCA", "accepted_name"] <- "Carex flacca"
  cleaned[cleaned$species == "Baby carlina_UKS", "accepted_name"] <- "Carlina"
  # return species table
  cleaned <- cleaned %>% select(-species)
  return(cleaned)
}
back to top