From e3553bd4821f8fd971cd3bed37123fb4815fb9a2 Mon Sep 17 00:00:00 2001 From: "Thomas J. Leeper" Date: Mon, 23 Jul 2018 11:05:40 +0100 Subject: [PATCH] coerce data to cj_df in cj() --- DESCRIPTION | 4 ++-- NEWS.md | 4 ++++ R/amce_diffs.R | 3 +++ R/cj.R | 3 +++ 4 files changed, 12 insertions(+), 2 deletions(-) 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 ~ . ))