Make a projoint_data
object from a labelled tibble
Source: R/make_projoint_data.R
make_projoint_data.Rd
Converts 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.
Usage
make_projoint_data(
.dataframe,
.attribute_vars,
.id_var = "id",
.task_var = "task",
.profile_var = "profile",
.selected_var = "selected",
.selected_repeated_var = NULL,
.fill = FALSE
)
Arguments
- .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
"id"
.- .task_var
Column name (character) with task numbers. Default
"task"
.- .profile_var
Column name (character) with profile numbers. Default
"profile"
.- .selected_var
Column name (character) with the binary choice for each task (values in
{0,1}
). Default"selected"
.- .selected_repeated_var
Optional column name (character) with the binary choice for the repeated task. Default
NULL
.- .fill
Logical. If
TRUE
, uses repeated-task agreement to fill missing agreement values for non-repeated tasks (assumes IRR is independent of table content). If unsure, prefer the defaultFALSE
.
Value
A projoint_data
object (a list-like object containing a labels
tibble and a data
tibble) ready to pass to projoint
and related
functions.
Examples
# \donttest{
# 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"
# [1] "projoint_data"
# }