check.key: Check Index Key

View source: R/check.key.R

check.keyR Documentation

Check Index Key

Description

Checks whether a data frame's index key is unique or contains any missing values. An index key may be a single or combination of variables which uniquely identify data rows in a table. Index keys are important for merging data tables.

Usage

check.key(x, ...)

Arguments

x

Object.

key

Character string specifying an index key.

echo

Logical value specifying whether to print error messages to the R console.

Value

A character vector of error messages (invisible).

Examples

# Vector example:
x <- rpois(20, 5)
check.key(x) # Checks for repeat entries.

x <- data.frame(year = sample(2010:2014, 20, replace = TRUE),
                site = sample(LETTERS[1:5], 20, replace = 20),
                count = rpois(20, 5),
                value = rnorm(20))
x$year[sample(1:nrow(x), 3)] <- NA
check.key(x, key = c("year", "site"))


TobieSurette/gulf.manage documentation built on Feb. 10, 2024, 10:51 p.m.