compare_vars function

Compare pairs on given variables

Compare pairs on given variables

## S3 method for class 'cluster_pairs' compare_vars( pairs, variable, on_x = variable, on_y = on_x, comparator = cmp_identical(), new_name = NULL, ... ) compare_vars( pairs, variable, on_x = variable, on_y = on_x, comparator = cmp_identical(), ... ) ## S3 method for class 'pairs' compare_vars( pairs, variable, on_x = variable, on_y = on_x, comparator = cmp_identical(), x = attr(pairs, "x"), y = attr(pairs, "y"), inplace = FALSE, ... )

Arguments

  • pairs: data.table with pairs. Should contain the columns .x and .y.
  • variable: character vector with name of resulting column name that is added to pairs.
  • on_x: character vector with the column names from x on which to compare.
  • on_y: character vector with the column names from y on which to compare.
  • comparator: function with which the variables are compared. When on_x and on_y have length 1, this function should accept two vectors. Otherwise it will receive two data.tables. Function should either return a vector or a data.table with multiple columns.
  • new_name: name of new object to assign the pairs to on the cluster nodes.
  • ...: Passed on to the comparator function.
  • x: data.table with one half of the pairs.
  • y: data.table with the other half of the pairs.
  • inplace: logical indicating whether pairs should be modified in place. When pairs is large this can be more efficient.

Returns

Returns the data.table pairs with one or more columns added.

Details

When comparator returns a data.table multiple columns are added to pairs. The names of these columns are variable pasted together with the names of the data.table returned by comparator (separated by "_").

  • Maintainer: Jan van der Laan
  • License: GPL-3
  • Last published: 2024-02-09