R Under development (unstable) (2023-07-19 r84711 ucrt) -- "Unsuffered Consequences" Copyright (C) 2023 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library(reclin2) Loading required package: data.table Attaching package: 'reclin2' The following object is masked from 'package:base': identical > source("helpers.R") > > > data("linkexample1", "linkexample2") > linkexample1$id2 <- c(1,1,3,3,5,6) > linkexample2$id2 <- c(2,3,3,6,7) > > pairs <- pair_blocking(linkexample1, linkexample2, "postcode") > pairs[, score := runif(nrow(pairs))] First data set: 6 records Second data set: 5 records Total number of pairs: 17 pairs Blocking on: 'postcode' .x .y score 1: 1 1 0.26620705 2: 1 2 0.53517799 3: 1 3 0.15675725 4: 2 1 0.24971265 5: 2 2 0.71774280 6: 2 3 0.39375684 7: 3 1 0.27842934 8: 3 2 0.93067480 9: 3 3 0.51133765 10: 4 1 0.25484900 11: 4 2 0.97827497 12: 4 3 0.03870225 13: 5 1 0.67335571 14: 5 2 0.58496315 15: 5 3 0.61462588 16: 6 4 0.61759480 17: 6 5 0.48179762 > pairs[, select := score > 0.5] First data set: 6 records Second data set: 5 records Total number of pairs: 17 pairs Blocking on: 'postcode' .x .y score select 1: 1 1 0.26620705 FALSE 2: 1 2 0.53517799 TRUE 3: 1 3 0.15675725 FALSE 4: 2 1 0.24971265 FALSE 5: 2 2 0.71774280 TRUE 6: 2 3 0.39375684 FALSE 7: 3 1 0.27842934 FALSE 8: 3 2 0.93067480 TRUE 9: 3 3 0.51133765 TRUE 10: 4 1 0.25484900 FALSE 11: 4 2 0.97827497 TRUE 12: 4 3 0.03870225 FALSE 13: 5 1 0.67335571 TRUE 14: 5 2 0.58496315 TRUE 15: 5 3 0.61462588 TRUE 16: 6 4 0.61759480 TRUE 17: 6 5 0.48179762 FALSE > pairs[, select2 := FALSE] First data set: 6 records Second data set: 5 records Total number of pairs: 17 pairs Blocking on: 'postcode' .x .y score select select2 1: 1 1 0.26620705 FALSE FALSE 2: 1 2 0.53517799 TRUE FALSE 3: 1 3 0.15675725 FALSE FALSE 4: 2 1 0.24971265 FALSE FALSE 5: 2 2 0.71774280 TRUE FALSE 6: 2 3 0.39375684 FALSE FALSE 7: 3 1 0.27842934 FALSE FALSE 8: 3 2 0.93067480 TRUE FALSE 9: 3 3 0.51133765 TRUE FALSE 10: 4 1 0.25484900 FALSE FALSE 11: 4 2 0.97827497 TRUE FALSE 12: 4 3 0.03870225 FALSE FALSE 13: 5 1 0.67335571 TRUE FALSE 14: 5 2 0.58496315 TRUE FALSE 15: 5 3 0.61462588 TRUE FALSE 16: 6 4 0.61759480 TRUE FALSE 17: 6 5 0.48179762 FALSE FALSE > > > # === TESTS FOR ID_X AND ID_Y ARGUMENTS > > test <- reclin2:::select_preprocess(pairs, score = "score", id_x = "id", id_y = "id") > expect_equal(test$.x, linkexample1$id[pairs$.x]) > expect_equal(test$.y, linkexample2$id[pairs$.y]) > > test <- reclin2:::select_preprocess(pairs, score = "score", id_x = "id2", id_y = "id2") > expect_equal(test$.x, linkexample1$id2[pairs$.x]) > expect_equal(test$.y, linkexample2$id2[pairs$.y]) > > test <- reclin2:::select_preprocess(pairs, score = "score", id_x = "id2", id_y = "id2", + preselect = "select") > expect_equal(sort(test$.x), sort(linkexample1$id2[pairs$.x[pairs$select]])) > expect_equal(sort(test$.y), sort(linkexample2$id2[pairs$.y[pairs$select]])) > > test <- reclin2:::select_preprocess(pairs, score = "score", id_x = "id2", id_y = "id2", + preselect = "select2") > expect_equal(nrow(test), 0) > expect_equal(names(test), c(".x", ".y", "score", "index")) > > expect_error( + test <- reclin2:::select_preprocess(pairs, score = "score", id_x = 1:3, id_y = 1:3, + preselect = "select") + ) > > proc.time() user system elapsed 0.31 0.07 0.37