Skip to contents

Several function factories have been implemented to create replacement functions (make_hashing_replacement(), make_random_replacement()).

Usage

auto_replace(frm, replacement_func, filter = FALSE)

Arguments

frm

A data.frame with columns If, From, and To.

replacement_func

A function for transforming the To column.

filter

Logical. If TRUE will only apply to rows where From and To are different.

Value

A data.frame like frm but with the To column transformed by replacement_func.

Examples


replace_by <- make_random_replacement()
auto_replace(raw_redaction_rules, replacement_func = replace_by)
#> # A tibble: 10 × 3
#>    If                                                                From  To   
#>    <chr>                                                             <chr> <chr>
#>  1 "[Scene: Central Perk, everyone is there.]"                       Cent… MWLE…
#>  2 "[Scene: Central Perk, everyone is there.]"                       Perk  EEXO…
#>  3 "Oh, Ross, Mon, is it okay if I bring someone to your parent's a… Ross  ULBF…
#>  4 "Oh, Ross, Mon, is it okay if I bring someone to your parent's a… Mon   KGUF…
#>  5 "Well, his name is Parker and I met him at the drycleaners."      Park… TXVA…
#>  6 "Every year Ross makes the toast, and it's always really moving,… Ross  ULBF…
#>  7 "And you wonder why Ross is their favorite?"                      Ross  ULBF…
#>  8 "Any time Ross makes a toast everyone cries, and hugs him, and p… Ross  ULBF…
#>  9 "[Scene: Chandler and Monica's, they're getting ready to leave f… Chan… OREH…
#> 10 "[Scene: Chandler and Monica's, they're getting ready to leave f… Moni… CBWJ…