knitr::opts_chunk$set(collapse = T, comment = "#>") library(laycUtils)
The fuzzy_join() function merges datasets that don't have any common id to merge them on. For instance, two different datasets can contain both first name
, and last name
information, but due to typos, discrepancies will exist between the two datasets.
data(eto) head(eto) data(nwea) head(nwea)
Both data sets contains first name
and last name
. We will create a custom id variable based on names.
eto$my_id <- create_id(eto, var = c('lname', 'fname')) head(eto) nwea$my_id <- create_id(nwea, var = c('StudentLastName', 'StudentFirstName')) head(nwea)
df <- fuzzy_join(x = nwea, y = eto, by = 'my_id') head(df)
Both data sets have been merged. A new variable match_status
identifies whether the match was perfect
, partial
, or if the record was unmatched
"Thanks @psychemedia for most of the code" (via)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.