| check.key | R Documentation | 
Check for violation of a (primary) key constraint
check.key(x, cols, silent = FALSE)
x | 
 Data frame representing a table of a data base.  | 
cols | 
 Names of the colum(s) of   | 
silent | 
 Logical. If   | 
TRUE if the check was passed successfully and
FALSE otherwise.
The function performs a check for duplicates (using 
check.unique) and missing values
(using check.notnull). If cols has length > 1,
this is interpreted as a composite key (and not as a set of
individual key columns). See the examples.
David Kneis david.kneis@tu-dresden.de
There are more functions to check constraints, namely
check.notnull, check.unique,
and check.link.
See also the example for db.read.
data(temperature)
print(temperature)
# Should succeed
check.key(temperature, c("day", "city"))
# Duplicates not allowed in keys
temperature[2, "day"] <- 1
print(temperature)
check.key(temperature, c("day", "city"))
# Missing values not allowed in keys
temperature[2, "day"] <- NA
check.key(temperature, c("day", "city"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.