Learn R Programming

SSBtools (version 1.8.4)

data_diff_groups: Add diff_groups results as columns in a data frame

Description

data_diff_groups() is a wrapper around diff_groups() that runs the same analysis on two variables in a data frame and adds selected results back as new columns.

Usage

data_diff_groups(
  data,
  input_vars,
  output_vars = c(is_common = "is_common", diff_1_2 = "diff_1_2", diff_2_1 = "diff_2_1",
    sum_1_2 = "sum_1_2", sum_2_1 = "sum_2_1"),
  ...
)

Value

A data frame identical to data, but with additional variables describing relationships between the two specified columns.

Arguments

data

A data frame containing the variables to be compared.

input_vars

Character vector of length two specifying the names of the two variables in data to be compared.

output_vars

Named character vector defining which variables from the group results are added to data, and what their names will be in the output.

...

Additional arguments passed to diff_groups().

Examples

Run this code
df <- cbind(v1 = 1, SSBtoolsData("code_pairs"), v4 = 4)

data_diff_groups(df, input_vars = c("code_1", "code_2"))

Run the code above in your browser using DataLab