R Under development (unstable) (2024-01-31 r85845 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 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 > 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.27419415 2: 1 2 0.56777076 3: 1 3 0.17351057 4: 2 1 0.27617001 5: 2 2 0.95404493 6: 2 3 0.31544355 7: 3 1 0.76453290 8: 3 2 0.91346322 9: 3 3 0.45524865 10: 4 1 0.15560062 11: 4 2 0.07531252 12: 4 3 0.82084235 13: 5 1 0.94760515 14: 5 2 0.22172045 15: 5 3 0.02280451 16: 6 4 0.40029323 17: 6 5 0.77482137 > 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.27419415 FALSE 2: 1 2 0.56777076 TRUE 3: 1 3 0.17351057 FALSE 4: 2 1 0.27617001 FALSE 5: 2 2 0.95404493 TRUE 6: 2 3 0.31544355 FALSE 7: 3 1 0.76453290 TRUE 8: 3 2 0.91346322 TRUE 9: 3 3 0.45524865 FALSE 10: 4 1 0.15560062 FALSE 11: 4 2 0.07531252 FALSE 12: 4 3 0.82084235 TRUE 13: 5 1 0.94760515 TRUE 14: 5 2 0.22172045 FALSE 15: 5 3 0.02280451 FALSE 16: 6 4 0.40029323 FALSE 17: 6 5 0.77482137 TRUE > 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.27419415 FALSE FALSE 2: 1 2 0.56777076 TRUE FALSE 3: 1 3 0.17351057 FALSE FALSE 4: 2 1 0.27617001 FALSE FALSE 5: 2 2 0.95404493 TRUE FALSE 6: 2 3 0.31544355 FALSE FALSE 7: 3 1 0.76453290 TRUE FALSE 8: 3 2 0.91346322 TRUE FALSE 9: 3 3 0.45524865 FALSE FALSE 10: 4 1 0.15560062 FALSE FALSE 11: 4 2 0.07531252 FALSE FALSE 12: 4 3 0.82084235 TRUE FALSE 13: 5 1 0.94760515 TRUE FALSE 14: 5 2 0.22172045 FALSE FALSE 15: 5 3 0.02280451 FALSE FALSE 16: 6 4 0.40029323 FALSE FALSE 17: 6 5 0.77482137 TRUE 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.54 0.14 0.67