View source: R/make_projoint_data.R
| make_projoint_data | R Documentation |
projoint_data object from a labelled tibbleConverts a labelled tibble/data frame (one column per attribute) into an object
of class projoint_data that downstream functions (e.g., projoint)
can consume. The unit of observation should be each of two profiles in each task
for each respondent.
make_projoint_data(
.dataframe,
.attribute_vars,
.id_var = "id",
.task_var = "task",
.profile_var = "profile",
.selected_var = "selected",
.selected_repeated_var = NULL,
.fill = FALSE
)
.dataframe |
A data frame (or tibble). One row per profile per task per respondent. |
.attribute_vars |
Character vector of attribute column names. |
.id_var |
Column name (character) with respondent IDs. Default |
.task_var |
Column name (character) with task numbers. Default |
.profile_var |
Column name (character) with profile numbers. Default |
.selected_var |
Column name (character) with the binary choice for each task
(values in |
.selected_repeated_var |
Optional column name (character) with the binary choice
for the repeated task. Default |
.fill |
Logical. If |
A projoint_data object (a list-like object containing a labels
tibble and a data tibble) ready to pass to projoint and related
functions.
# Example: build a projoint_data object from the labelled-tibble example
data(exampleData1_labelled_tibble)
att_cols <- c("School Quality", "Violent Crime Rate (Vs National Rate)",
"Racial Composition", "Housing Cost",
"Presidential Vote (2020)",
"Total Daily Driving Time for Commuting and Errands",
"Type of Place")
pj_dat <- make_projoint_data(
.dataframe = exampleData1_labelled_tibble,
.attribute_vars = att_cols,
.id_var = "id",
.task_var = "task",
.profile_var = "profile",
.selected_var = "selected",
.selected_repeated_var = "selected_repeated",
.fill = FALSE
)
class(pj_dat)
# [1] "projoint_data"
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.