fix_names: Change taxonomic names to be the same for each taxon

Description Usage Arguments Value Examples

View source: R/fix_names.R

Description

That is, this function attempts to take all the names that are synonyms, for whatever reason (e.g., some names have authorities on them), and collapses them to the same string - making data easier to deal with for making maps, etc. OR - you can think of this as a tool for

Usage

1
fix_names(x, how = "shortest", replace = NULL)

Arguments

x

(data.frame) A data.frame. the target taxonomic name column should be 'name'

how

One of a few different methods:

  • shortest - Takes the shortest name string that is likely to be the prettiest to display name, and replaces alll names with that one, better for maps, etc.

  • supplied - If this method, supply a vector of names to replace the names with.

replace

A data.frame of names to replace names in the occurrence data.frames with. Only used if how="supplied". The data.frame should have two columns: the first is the names to match in the input x data.frame, and the second column is the name to replace with. The column names don't matter.

Value

a data.frame

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
## Not run: 
df <- sample_data_7

# method: shortest
fix_names(df, how="shortest")$name

# method: supplied
(replace_df <- data.frame(
 one = unique(df$name), 
 two = c('P. contorta', 'P.c. var. contorta',
         'P.c. subsp bolanderi', 'P.c. var. murrayana'),
 stringsAsFactors = FALSE))
fix_names(df, how="supplied", replace = replace_df)$name

## End(Not run)

scrubr documentation built on June 12, 2021, 9:06 a.m.