fold change calculation which returns a extensible tibble
Usage
stat_fc(
df,
y,
x,
method = "mean",
.by = NULL,
rev_div = FALSE,
digits = 2,
fc_fmt = "short",
suffix = "x"
)
Arguments
- df
tibble
- y
value
- x
sample test group
- method
'mean'|'median'|'geom_mean'
, the summary method- .by
super-group
- rev_div
reverse division
- digits
fold change digits
- fc_fmt
fold change format, one of short, signif, round
- suffix
suffix of fold change,
x
as default
Examples
stat_fc(mini_diamond, y = price, x = cut, .by = clarity)
#> # A tibble: 24 × 8
#> y clarity group1 group2 y1 y2 fc fc_fmt
#> <chr> <chr> <chr> <chr> <dbl> <dbl> <dbl> <chr>
#> 1 price I1 Fair Good 4695. 2760. 1.70 1.7x
#> 2 price I1 Fair Ideal 4695. 4249 1.11 1.1x
#> 3 price I1 Good Ideal 2760. 4249 0.649 0.65x
#> 4 price IF Fair Good 2016 1044. 1.93 1.9x
#> 5 price IF Fair Ideal 2016 962. 2.10 2.1x
#> 6 price IF Good Ideal 1044. 962. 1.09 1.1x
#> 7 price SI1 Fair Good 5844. 3227. 1.81 1.8x
#> 8 price SI1 Fair Ideal 5844. 3877. 1.51 1.5x
#> 9 price SI1 Good Ideal 3227. 3877. 0.832 0.83x
#> 10 price SI2 Fair Good 13162. 6539. 2.01 2.0x
#> # ℹ 14 more rows