diff --git a/DESCRIPTION b/DESCRIPTION index 23a73ad..62b6aa0 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: cbcTools Title: Choice-Based Conjoint Experiment Design Generation and Power Evaluation in R -Version: 0.5.0 +Version: 0.5.1 Maintainer: John Helveston Authors@R: c( person(given = "John", diff --git a/NEWS.md b/NEWS.md index 3aefa11..e565711 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,9 @@ # cbcTools (development version) +# cbcTools 0.5.1 + +- Patch to fix a joining issue in the `join_profiles()` function (#27) + # cbcTools 0.5.0 - Further revisions to the `method` argument in the `cbc_design()` function. diff --git a/R/design.R b/R/design.R index 25cff31..008e678 100644 --- a/R/design.R +++ b/R/design.R @@ -312,6 +312,10 @@ get_type_ids <- function(profiles) { join_profiles <- function(design, profiles) { + # Preserve row order + + design$row_order <- seq(nrow(design)) + # Before joining profiles, ensure that all the data types are the same # as in profiles, otherwise join won't work properly @@ -330,6 +334,8 @@ join_profiles <- function(design, profiles) { # Join on profileIDs, then reorder to retain design order varnames <- names(profiles[, 2:ncol(profiles)]) design <- merge(design, profiles, by = varnames, all.x = TRUE, sort = FALSE) + design <- design[order(design$row_order),] + design$row_order <- NULL if ('blockID' %in% names(design)) { varnames <- c(varnames, 'blockID') } design <- design[c('profileID', varnames)] return(design)