lama_merge {labelmachine}R Documentation

Merge multiple lama-dictionaries into one

Description

This function takes multiple lama_dictionary class objects and merges them together into a single lama_dictionary class object. In case some class objects have entries with the same name, the class objects passed in later overwrite the class objects passed in first (e.g. in lama_merge(x, y, z): The lexicon z overwrites x and y. The lexicon y overwrites x).

Usage

lama_merge(..., show_warnings = TRUE)

## S3 method for class 'lama_dictionary'
lama_merge(..., show_warnings = TRUE)

Arguments

...

Two or more lama_dictionary class objects, which should be merged together.

show_warnings

A logical flag that defines, whether warnings should be shown (TRUE) or not (FALSE).

Value

The merged lama_dictionary class object

See Also

lama_translate(), lama_to_factor(), lama_translate_all(), lama_to_factor_all(), new_lama_dictionary(), as.lama_dictionary(), lama_rename(), lama_select(), lama_mutate(), lama_read(), lama_write()

Examples

  # initialize lama_dictinoary
  dict_1 <- new_lama_dictionary(
    subject = c(en = "English", ma = "Mathematics"),
    result = c("1" = "Very good", "2" = "Good", "3" = "Not so good")
  )
  dict_2 <- new_lama_dictionary(
    result = c("1" = "Super", "2" = "Fantastic", "3" = "Brilliant"),
    grade = c(a = "Primary School", b = "Secondary School")
  )
  dict_3 <- new_lama_dictionary(
    country = c(en = "England", "at" = "Austria", NA_ = "Some other country")
  )
  dict <- lama_merge(dict_1, dict_2, dict_3)
  # The lama_dictionary now contains the translations
  # 'subject', 'result', 'grade' and 'country'
  # The translation 'result' from 'dict_1' was overwritten by the 'result' in 'dict_2'
  dict

[Package labelmachine version 1.0.0 Index]