Coding objects can be linked together to create mappings from one or more codings to another. This creates a `data.frame` that outlines how the codings are linked, to be used in `make_recode_query()`.

link_codings(to, ..., .to_suffix = "to", .drop_unused = FALSE)

Arguments

to

A coding to be linked to

...

Codings to be linked from

.to_suffix

A suffix signifying which columns in the output `data.frame` came from `to`

.drop_unused

Logical flag to drop any codes in `...` that have no counterparts in `to`

Value

A `linked_coding_df` with all necessary information for a recoding query

Examples

wave1 <- coding(
  code("Yes", 1),
  code("No", 2),
  code("Refused", -88, missing = TRUE)
)
wave2 <- coding(
  code("Yes", "y"),
  code("No", "n"),
  code("Missing", ".", missing = TRUE)
)
link_codings(
  to = coding(
    code("Yes", 1),
    code("No", 0),
    code("Missing", NA, links_from = c("Refused", "Missing"))
  ),
  wave1,
  wave2
)
#>      link label_to value_to label_.x value_.x label_.y value_.y
#> 1 Missing  Missing       NA     <NA>       NA  Missing        .
#> 2      No       No        0       No        2       No        n
#> 3 Refused  Missing       NA  Refused      -88     <NA>     <NA>
#> 4     Yes      Yes        1      Yes        1      Yes        y