count_dupes {tablecompare} | R Documentation |
Check for duplicate rows
Description
count_dupes()
returns values of by
variables for which the .data
has
multiple rows, along with the number of rows for each combination of values.
assert_unique()
throws an error if there are multiple rows for any
combination of by
variable values
Usage
count_dupes(.data, by, setkey = FALSE)
assert_unique(.data, by, data_chr, by_chr)
Arguments
.data |
A data frame or data table |
by |
tidy-select. Columns in |
setkey |
Logical. Should the output be keyed by |
data_chr |
optional. character. You can use this argument to manually specify
the name of |
by_chr |
optional. character. You can use this argument to manually specify
the name of |
Value
count_dupes()
A
data.table
with the (filtered)by
columns and an additional column "n_rows" which shows the number of rows in.data
having the combination ofby
values shown in the output row.assert_unique()
No return value. Called to throw an error depending on the input.
Examples
df <- read.table(text = "
x y z
1 6 1
2 6 2
3 7 3
3 7 4
4 3 5
4 3 6
", header = TRUE)
count_dupes(df, c(x, y))
## Not run:
assert_unique(df, c(x, y))
## End(Not run)