count_dupes | R Documentation |
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
count_dupes(.data, by, setkey = FALSE)
assert_unique(.data, by, data_chr, by_chr)
.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 |
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 of by
values shown in the output
row.
assert_unique()
No return value. Called to throw an error depending on the input.
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.