check.unique | R Documentation |
Check for violation of a unique constraint
check.unique(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.
If cols
has length > 1, uniqueness is checked for the
combination of columns rather than for each column individually. See
the examples.
David Kneis david.kneis@tu-dresden.de
There are more functions to check constraints, namely
check.notnull
, check.key
,
and check.link
.
See also the example for db.read
.
data(temperature) print(temperature) # Should succeed check.unique(temperature, c("day", "city")) # Example of duplicates temperature[2, "day"] <- 1 print(temperature) check.unique(temperature, c("day", "city"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.