diff --git a/DESCRIPTION b/DESCRIPTION index 703bfec..84247b5 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: cregg Type: Package Title: Simple Conjoint Tidying, Analysis, and Visualization -Version: 0.2.3 -Date: 2018-07-10 +Version: 0.2.4 +Date: 2018-07-23 Authors@R: c(person("Thomas J.", "Leeper", role = c("aut", "cre"), email = "thosjleeper@gmail.com", comment = c(ORCID = "0000-0003-4097-6326"))) diff --git a/NEWS.md b/NEWS.md index 89cf6a6..ee105e9 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +# cregg 0.2.4 + +* `cj()` now imposes class "cj_df" on `data` to preserve attributes during subsetting. + # cregg 0.2.3 * Added function `cj_table()`, which can be useful in communicating the set of features and levels used in the design as a data frame (e.g,. using `knitr::kable(cj_table(data, ~ feat1 + feat2))`). diff --git a/R/amce_diffs.R b/R/amce_diffs.R index 8b007a5..aa4d001 100644 --- a/R/amce_diffs.R +++ b/R/amce_diffs.R @@ -68,6 +68,9 @@ function( ... ) { + # coerce to "cj_df" to preserve attributes + data <- cj_df(data) + # get outcome variable outcome <- all.vars(stats::update(formula, . ~ 0)) diff --git a/R/cj.R b/R/cj.R index 221f70b..a9015de 100644 --- a/R/cj.R +++ b/R/cj.R @@ -15,6 +15,9 @@ function( ) { estimate <- match.arg(estimate) + # coerce to "cj_df" to preserve attributes + data <- cj_df(data) + if (!is.null(by)) { # get RHS variables, variable labels, and factor levels RHS <- all.vars(stats::update(formula, 0 ~ . ))