This function calculates percentage statistics based on a given dataset and grouping variables.

PercentageStat(cellmeta, by, fill)

Arguments

cellmeta

A data frame containing cell metadata.

by

A character vector specifying the variable(s) used to group the data.

fill

A character vector specifying the variable used to fill the data.

Value

A data frame containing the calculated percentage statistics.

Examples

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