link_codings: Link a coding from others for recoding

View source: R/linking.R

link_codingsR Documentation

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)

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
)

rcoder documentation built on Oct. 6, 2023, 9:06 a.m.