A minimal function which counts the number of observations by groups in a data frame
Source:R/jointfuns.R
jointfun_.Rd
A minimal function which counts the number of observations by groups in a data frame
Value
a data frame, with a column for each cateogrical variable used, and a row for each combination of all the categorical variables' modalities.
Examples
data("invented_wages")
tmp <- jointfun_(.data = invented_wages, .variables = c("gender", "sector"))
tmp
#> # A tibble: 4 × 3
#> # Groups: gender [2]
#> gender sector n
#> <fct> <fct> <int>
#> 1 men secondary 289
#> 2 men tertiary 258
#> 3 women secondary 166
#> 4 women tertiary 287
str(tmp)
#> gropd_df [4 × 3] (S3: grouped_df/tbl_df/tbl/data.frame)
#> $ gender: Factor w/ 2 levels "men","women": 1 1 2 2
#> $ sector: Factor w/ 2 levels "secondary","tertiary": 1 2 1 2
#> $ n : int [1:4] 289 258 166 287
#> - attr(*, "groups")= tibble [2 × 2] (S3: tbl_df/tbl/data.frame)
#> ..$ gender: Factor w/ 2 levels "men","women": 1 2
#> ..$ .rows : list<int> [1:2]
#> .. ..$ : int [1:2] 1 2
#> .. ..$ : int [1:2] 3 4
#> .. ..@ ptype: int(0)
#> ..- attr(*, ".drop")= logi TRUE