This function calculates percentage statistics based on a given dataset and grouping variables.
PercentageStat(cellmeta, by, fill)
A data frame containing cell metadata.
A character vector specifying the variable(s) used to group the data.
A character vector specifying the variable used to fill the data.
A data frame containing the calculated percentage statistics.
PercentageStat(mtcars, "cyl", "gear")
#> # A tibble: 9 × 5
#> # Groups: cyl [3]
#> cyl gear Freq margin.freq proportion
#> <fct> <fct> <int> <int> <dbl>
#> 1 4 3 1 11 0.0909
#> 2 6 3 2 7 0.286
#> 3 8 3 12 14 0.857
#> 4 4 4 8 11 0.727
#> 5 6 4 4 7 0.571
#> 6 8 4 0 14 0
#> 7 4 5 2 11 0.182
#> 8 6 5 1 7 0.143
#> 9 8 5 2 14 0.143