compare_vars: Compare pairs on given variables

View source: R/compare_vars.R

compare_vars.cluster_pairsR Documentation

Compare pairs on given variables

Description

Compare pairs on given variables

Usage

## 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.

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 "_").

Value

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


reclin2 documentation built on May 29, 2024, 4:21 a.m.