leeper / cregg

Simple Conjoint Analyses, Tidying, and Visualization
Other
50 stars 7 forks source link

cj(..., by = ) operations produce faulty results when by factor has blank levels #32

Closed leeper closed 4 years ago

leeper commented 4 years ago

Please specify whether your issue is about:

Reported by Farsan Ghassim via email:

## load package
library("cregg")

## code goes here
iris$foo <- factor(c("a", "b", ""))
cregg::cj(iris, Sepal.Length ~ Species, estimate = "mm", by = ~ foo)
##   BY      outcome statistic feature      level estimate  std.error        z p    lower    upper foo
## 1    Sepal.Length        mm Species versicolor 6.023529 0.13406704 44.92923 0 5.760763 6.286296   a
## 2    Sepal.Length        mm Species     setosa 4.950000 0.09657727 51.25430 0 4.760712 5.139288   a
## 3    Sepal.Length        mm Species  virginica 6.570588 0.15190449 43.25473 0 6.272861 6.868316   a
## 4  a Sepal.Length        mm Species  virginica 6.756250 0.14368309 47.02189 0 6.474636 7.037864   b
## 5  a Sepal.Length        mm Species     setosa 5.052941 0.09286290 54.41291 0 4.870933 5.234949   b
## 6  a Sepal.Length        mm Species versicolor 5.770588 0.12793126 45.10694 0 5.519848 6.021329   b

## session info for your system
sessionInfo()