set_label: Set a private field for a Survey object.

Description Usage Arguments Note Author(s) Examples

View source: R/accessors.R

Description

Like the get_ functions with the same name, these functions provide a familiar interface to set the hidden fields of a Survey object.

Usage

1
2
3
4
5
6
7
8
9
set_label(.srv, ..., .list = NULL, .auto = FALSE)

set_association(.srv, ..., .list = NULL, .common = FALSE)

set_marketshare(.srv, ..., .list = NULL)

set_config(.srv, ..., .list = NULL)

set_translation(.srv, ..., .list = NULL, .language = NULL)

Arguments

.srv

A Survey object.

...

Named arguments of the format name = value, with the exception of set_association which uses value = name.

.list

Optional: A list (or named character vector) the same format as ....

.auto

Optional: Set to TRUE if you want to automatically set labels for EM variables and latents (if translations are set).

.common

Optional: Set to TRUE if you want associations to be set for common variable names. E.g., q1 is set as mainentity, and q4a-z is associated with image.

.language

Optional: Language defaults to use for translations.

Note

These functions return a copy (deep_clone) of the Survey. Use the R6 method directly to avoid copying.

Author(s)

Kristian D. Olsen

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# Create a new survey (regular)
x <- survey_df(data.frame("A" = 1, "B" = 2))
x <- set_label(x, A = "This is a label")
get_label(x, "A")

# Same example using R6
y <- survey_df(data.frame("A" = 1, "B" = 2))
y$set_label(A = "This is a label")
y$get_label("A")

# Should be equivalent
all.equal(x, y)

itsdalmo/reporttoolDT documentation built on May 18, 2019, 7:11 a.m.