| read_labels | R Documentation |
Reads a CSV containing a revised ordering of attributes and levels and applies it
to an existing projoint_data object. Typical workflow: first save the
current labels to CSV (e.g., with save_labels), manually reorder rows
(and/or the attribute grouping) in the CSV, then call read_labels() to apply.
read_labels(.data, .filename)
.data |
A |
.filename |
Path to the revised labels CSV (originally produced from the package's labels). |
A projoint_data object with the same content as .data but with
attributes and levels reordered to match the CSV. The returned object contains:
$labels: a tibble with new attribute_id and level_id reflecting the chosen order
$data: a tibble whose att* columns have been remapped to the new level_ids
save_labels, reshape_projoint
# Create a projoint_data object from the example dataset
data(exampleData1)
outcomes <- c(paste0("choice", 1:8), "choice1_repeated_flipped")
pj <- reshape_projoint(exampleData1, outcomes)
# Write current labels to a temporary CSV, adding an 'order' column
tmp <- tempfile(fileext = ".csv")
pj$labels |>
dplyr::mutate(order = dplyr::row_number()) |>
readr::write_csv(tmp)
# (User would reorder rows in 'tmp' manually; we just read it back)
pj_reordered <- read_labels(pj, tmp)
# Inspect the updated label order
head(pj_reordered$labels)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.