Saves the attributes and levels (and their order) from a projoint_data
object, as generated by reshape_projoint
, to a CSV file. This
enables manual reordering and later re-import via read_labels
.
Arguments
- .data
A
projoint_data
object.- .filename
A character string giving the name of a CSV file to be written.
Examples
# \donttest{
library(projoint)
data(exampleData1)
reshaped <- reshape_projoint(
exampleData1,
.outcomes = c(paste0("choice", 1:8), "choice1_repeated_flipped")
)
tmpfile <- tempfile(fileext = ".csv")
save_labels(reshaped, tmpfile)
readLines(tmpfile, n = 5) # show first few lines
#> [1] "level_id,attribute,level,order"
#> [2] "att1:level1,Housing Cost,15% of pre-tax income,1"
#> [3] "att1:level2,Housing Cost,30% of pre-tax income,2"
#> [4] "att1:level3,Housing Cost,40% of pre-tax income,3"
#> [5] "att2:level1,Presidential Vote (2020),\"30% Democrat, 70% Republican\",4"
# }