-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExample script calc_match_person.R
45 lines (35 loc) · 1.71 KB
/
Example script calc_match_person.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# personMatchR example code: calc_match_person() function
#
# created on 2022-10-25
#
# this code shows an example script running the matching process on flat file datasets
# Install and load required packages ----------------------------------------------------------
devtools::install_github("nhsbsa-data-analytics/personMatchR")
library("dplyr")
library("dbplyr")
# Import datasets for matching ----------------------------------------------------------------
df_a <- personMatchR::TEST_DF_A
df_b <- personMatchR::TEST_DF_B
# Review the test datasets --------------------------------------------------------------------
df_a
df_b
# Run the personMatchR package to identify matches --------------------------------------------
df_output <- personMatchR::calc_match_person(
df_one = df_a, # first dataset
id_one = ID, # unique id field from first dataset
forename_one = FORENAME, # forename field from first dataset
surname_one = SURNAME, # surname field from first dataset
dob_one = DOB, # date of birth field from first dataset
postcode_one = POSTCODE, # postcode field from first dataset
df_two = df_b, # second dataset
id_two = ID, # unique id field from second dataset
forename_two = FORENAME, # forename field from second dataset
surname_two = SURNAME, # surname field from second dataset
dob_two = DOB, # date of birth field from second dataset
postcode_two = POSTCODE, # postcode field from second dataset
output_type = "key", # only return the key match results
format_data = TRUE, # format input datasets prior to matching
inc_no_match = TRUE # return records from first dataset without matches
)
# Review the match output ---------------------------------------------------------------------
df_output