check_ids: Check for and omit non-animal animal ids

View source: R/housekeeping.R

check_idsR Documentation

Check for and omit non-animal animal ids

Description

This function pads all short ids with leading zeros, then compares the animal ids in your data file to those in an index file. Any ids matched to a species with a value in the omit_animal argument will be omitted from the data set.

Usage

check_ids(r, ids, omit = c("wand", "error"), id_length = 10, bird_ids)

Arguments

r

Data frame. A data frame of read data, with at least column animal_id.

ids

Character or Data frame. Either the name and location of a .csv file containing the animal id index or a data frame of the animal id index. In either case, the data must contain two columns: animal_id and species.

omit

Character vector. All the values of species in the animal id index which you would like to omit from your data. Defaults to c("wand", "error").

id_length

Numeric. How many characters are expected in each id? This will test to make sure all ids are the right length (i.e. make sure leading zeros haven't been omitted). NA skips this test.

bird_ids

Deprecated.

Details

This is useful for removing ids you know are errors (e.g., 0000000000) or which you know are wands.

Value

A data frame without the specified animal ids. Messages are printed to inform the user of matching or non-matching animal ids.

Examples

## Not run: 
r <- check_ids(finches, ids = "animal_index.csv")

index <- read.csv("animal_index.csv")
r <- check_ids(finches, ids = index)

## End(Not run)

steffilazerte/feedr documentation built on Jan. 27, 2023, 3:46 a.m.