Removes all the rows where variables have value .total
.
Value
a subset of the data cube with only the combinations of all variables modalities, without the "margins".
Examples
data(invented_wages)
str(invented_wages)
#> tibble [1,000 × 5] (S3: tbl_df/tbl/data.frame)
#> $ gender : Factor w/ 2 levels "men","women": 1 2 1 2 1 1 1 2 2 2 ...
#> $ sector : Factor w/ 2 levels "secondary","tertiary": 2 1 2 2 1 1 2 1 2 1 ...
#> $ education : Factor w/ 3 levels "I","II","III": 3 2 2 2 2 1 3 1 2 2 ...
#> $ wage : num [1:1000] 8400 4200 5100 7400 4300 4900 5400 2900 4500 3000 ...
#> $ sample_weights: num [1:1000] 105 32 36 12 21 46 79 113 34 32 ...
vars <- c("gender", "education")
tmp <- dcc2(
.data = invented_wages,
.variables = vars,
.fun = jointfun_,
order_type = extract_unique2
)
#>
|
| | 0%
|
|=================================== | 50%
|
|======================================================================| 100%
tmp
#> # A tibble: 12 × 3
#> gender education n
#> * <fct> <fct> <int>
#> 1 Totale Totale 1000
#> 2 Totale I 172
#> 3 Totale II 719
#> 4 Totale III 109
#> 5 men Totale 547
#> 6 men I 60
#> 7 men II 409
#> 8 men III 78
#> 9 women Totale 453
#> 10 women I 112
#> 11 women II 310
#> 12 women III 31
str(tmp)
#> tibble [12 × 3] (S3: tbl_df/tbl/data.frame)
#> $ gender : Factor w/ 3 levels "Totale","men",..: 1 1 1 1 2 2 2 2 3 3 ...
#> $ education: Factor w/ 4 levels "Totale","I","II",..: 1 2 3 4 1 2 3 4 1 2 ...
#> $ n : int [1:12] 1000 172 719 109 547 60 409 78 453 112 ...
#> - attr(*, ".variables")= chr [1:2] "gender" "education"
only_joint(tmp, .variables = vars)
#> # A tibble: 6 × 3
#> gender education n
#> <fct> <fct> <int>
#> 1 men I 60
#> 2 men II 409
#> 3 men III 78
#> 4 women I 112
#> 5 women II 310
#> 6 women III 31
# Compare dimensions (number of groups)
dim(tmp)
#> [1] 12 3
dim(only_joint(tmp, .variables = vars))
#> [1] 6 3