lama_select {labelmachine}R Documentation

Select multiple variable translations and create a new lama_dictionary object

Description

The functions lama_select() and lama_select_() pick one or more variable translations from a lama_dictionary class object and create a new lama_dictionary class object. The function lama_select() uses non-standard evaluation, whereas lama_select_() is the standard evaluation alternative.

Usage

lama_select(.data, ...)

## S3 method for class 'lama_dictionary'
lama_select(.data, ...)

lama_select_(.data, key)

## S3 method for class 'lama_dictionary'
lama_select_(.data, key)

Arguments

.data

A lama_dictionary object, holding the variable translations

...

One or more unquoted translation names separated by commas.

key

A character vector holding the names of the variable translations that should be picked.

Value

A new lama_dictionary class object, holding the picked variable translations.

See Also

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

Examples

  # initialize lama_dictinoary
  dict <- new_lama_dictionary(
    country = c(uk = "United Kingdom", fr = "France", NA_ = "other countries"),
    language = c(en = "English", fr = "French"),
    result = c("1" = "Very good", "2" = "Good", "3" = "Not so good")
  )

  ## Example-1: Usage of 'lama_select'
  # pick the translations 'result' and 'language'
  # and add them to a new lama_dictionary
  dict_sub <- lama_select(dict, result, language)
  dict_sub
  
  ## Example-2: Usage of 'lama_select_'
  # pick the translations 'result' and 'language'
  # and add them to a new lama_dictionary
  dict_sub <- lama_select_(dict, c("result", "language"))
  dict_sub

[Package labelmachine version 1.0.0 Index]