| diff_groups | R Documentation |
This function is a wrapper around RowGroups() for the specific case where the input
contains two columns. It calls RowGroups() with returnGroups = TRUE, and extends
the resulting data frame of unique code combinations with additional information
about common groups, difference groups, and sum groups.
diff_groups(
x,
...,
hiddenNA = TRUE,
sep_common = "_=_",
sep_diff = "_-_",
sep_sum = c("_=_", "_+_"),
outputNA = "NA"
)
x |
A data frame with exactly two columns. |
... |
Additional arguments passed to |
|
Logical. When | |
sep_common |
A character string used in the |
sep_diff |
A character string used in the |
sep_sum |
A character vector of one or two elements used in the |
outputNA |
Character string used to represent |
The returned list contains the same elements as from RowGroups(), but with an
extended groups data frame. The columns describe relationships between the two
input columns as follows:
is_common — TRUE when the two codes on the row are identical.
is_child_1, is_child_2 — TRUE when the code in the column is a subset or
subgroup of a code in the other column.
common — identical code pairs, formatted using sep_common.
diff_1_2, diff_2_1 — difference groups. The first element is the parent
from the source column, followed by one or more child codes from the opposite
column, joined using sep_diff.
sum_1_2, sum_2_1 — sum groups where a parent code in one column equals the sum of several codes in the other.
A list (as returned by RowGroups()), where the groups data frame is
extended with additional descriptive columns indicating common, difference, and sum
relationships between the two code columns.
The parameter NAomit from RowGroups() can still be set via ..., but using it
will remove rows containing NA before processing. The relationships found will then
reflect the reduced data, which is usually not the intended behaviour when identifying
relationships between code sets.
data_diff_groups() for adding the results back as new columns in the data frame.
df <- SSBtoolsData("code_pairs")
df
diff_groups(df)
d2 <- SSBtoolsData("d2")
diff_groups(d2[1:2])$groups
diff_groups(d2[2:3])$groups
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.