| is_keycol {countries} | R Documentation |
Test whether a set of column could be a data frame key
Description
This function takes a data frame and a vector of column names as argument and returns a logical value indicating whether the indicated columns uniquely identify entries in the data frame.
If the output is TRUE, the indicated columns could be the keys of the table.
Usage
is_keycol(x, cols, allow_NA = FALSE, verbose = TRUE)
Arguments
x |
A data frame object |
cols |
A vector of column names or indices to be tested. |
allow_NA |
Logical value indicating whether to allow key columns to have |
verbose |
Logical value indicating whether messages should be printed on the console. Default is |
Value
Returns a logical value. If TRUE, the columns indicated in colnames uniquely identify the entries in x.
See Also
find_keycol, find_countrycol, find_timecol
Examples
is_keycol(data.frame(a=1:10,b=sample(c("a","b","c"),10, replace=TRUE)), cols="a")
is_keycol(data.frame(a=1:10,b=sample(c("a","b","c"),10, replace=TRUE)), cols="b")
is_keycol(
data.frame(a=c(1:5,1:5),
b=sample(c("a","b","c"),10, replace=TRUE),
c=c(rep("a",5),rep("b",5))),
cols=c("a","c"))
[Package countries version 1.2.0 Index]