Learn R Programming

rcoder (version 0.3.0)

link_codings: Link a coding from others for recoding

Description

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()`.

Usage

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

Value

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

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`

Examples

Run this code
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
)

Run the code above in your browser using DataLab