as_biomonitor: Import data into biomonitoR format

View source: R/as_biomonitor.R

as_biomonitorR Documentation

Import data into biomonitoR format

Description

This function merge the user data.frame with a reference dataset and suggest corrections for mispelled names.

Usage

as_biomonitor(
  x,
  group = "mi",
  dfref = NULL,
  to_change = "default",
  FUN = sum,
  correct_names = FALSE,
  traceB = FALSE
)

Arguments

x

A data.frame with a column called Taxa where store taxa names and samples on the other columns (see the example macro_ex).

group

Biotic group of interest. Possible values are mi for macroinvertebrates, mf for macrophytes, fi for fish and di for diatoms. The choice will set the right reference dataset for the specified group. This option will not be considered if a custom reference dataset is provided. Default to mi.

dfref

A custom reference database that replaces the built-in reference databases.

to_change

A data.frame specifying the taxa name that needs to be changed. This data.frame needs a column called Taxon containing taxa to aggregate and a column called Correct_Taxon with the aggregation specifications. By default, when group is set to mi Hydracarina, Hydracnidia and Acariformes are changed to Trombidiformes.

FUN

The function to be applied for aggregating rows with duplicated taxa names. It should be sum for abundances, while it should be bin for presence-absence data. Default to sum.

correct_names

If TRUE alternative names will be suggested for taxa not found in the reference dataset. Default to FALSE, with which the unrecognized taxa will be removed.

traceB

Track changes in taxa names.

Details

The function as_biomonitor() checks the taxonomy of the data.frame provided by the user and suggests correction for mispelled names. If one or more taxa names of x are not present in the reference dataset or the spell checker is not able to find any suggestion the user is asked to exit. This behaviour is to assure consistency with other functions implemented in biomonitoR. Default references databases are provided for macroinvertebrates, macrophytes and fish. Reference datasets heavily rely on the information provided by the freshwaterecology.info website. If dfref is not NULL a custom dictionary will be saved in the working directory to let the as_biomonitor () function work correctly. If you are unable to build a reference database by your own please check the function ref_from_tree for a possible solution. as_biomonitor() returns an object of class asb togheter with one of the classes abundance or bin. The function quick_rename works as the as_biomonitor() but returns a data.frame without the biomonitoR format. as_biomonitor() aggregates all the rows with the same taxa name with the option FUN and converts all the NA to 0. When group = mi Hydracarina, Hydracnidia or Acariformes are changed to Trombidiformes given the uncertain taxonomic status of this group.

References

Schmidt-Kloiber, A., & Hering, D. (2015). www.freshwaterecology.info - An online tool that unifies, standardises and codifies more than 20,000 European freshwater organisms and their ecological preferences. Ecological indicators, 53, 271-282.

See Also

quick_rename ref_from_tree

Examples

data(mi_prin)
data_bio <- as_biomonitor(mi_prin, group = "mi")

alexology/biomonitoR documentation built on April 7, 2024, 10:15 a.m.