matchNearestNeighbor {CornerstoneR}R Documentation

Match Nearest Neighbor Between Two Datasets

Description

Match the nearest neighbor from a redirected Cornerstone Robject dataset (redirectDataset) to corresponding selected predictor variables. Predictor variables from both datasets are supposed to be numeric to apply the Euclidean distance calculated by dist2. The function returns a dataset with the nearest neighbor to every observation, matched by the predictor variables. Available response, group, and auxiliary variables from the redirected datasets are passed through, as well as, selected auxiliary variables. The calculated distance is attached.

Usage

matchNearestNeighbor(
  dataset = cs.in.dataset(),
  preds = cs.in.predictors(),
  auxs = cs.in.auxiliaries(),
  robject = cs.in.Robject(),
  return.results = FALSE
)

Arguments

dataset

[data.frame]
Dataset with named columns. The names correspond to predictors and responses.

preds

[character]
Character vector of predictor variables.

auxs

[character]
Character vector of auxiliary variables.

robject

[list]
Named list of one redirectDataset object(s) set via Cornerstone menu "Input R Objects".

return.results

[logical(1)]
If FALSE the function returns TRUE invisibly. If TRUE, it returns a list of results. Default is FALSE.

Value

Logical [TRUE] invisibly and outputs to Cornerstone or, if return.results = TRUE, list of resulting data.frame objects:

nearest.neighbor

Matched nearest neighbor which consists of predictor and available response, group, and auxiliary variables. The calculated distance is attached to this dataset.

runtimes

Run times for every input R object.


[Package CornerstoneR version 2.0.2 Index]