This is a helper to allow srvyr's syntactic style. In general, users will not have to worry about setting variables in a survey object unless they are trying to extend srvyr. This function helps convert a vector to a variable in the correct part of a survey object's structure so that functions can refer to it using the survey package's formula notation. See vignette("extending-srvyr") for more details.

set_survey_vars(.svy, x, name = "__SRVYR_TEMP_VAR__", add = FALSE)

Arguments

.svy

A survey object

x

A vector to be included in the variables portion of the survey object

name

The name of the variable once it is added. Defaults to `__SRVYR_TEMP_VAR__` which is formatted weirdly to avoid name collisions.

add

FALSE, the default, overwrite all current variables. If TRUE, will add this variable instead.

Value

a tbl_svy with the variables modified