
Compare a metric between two datasets (e.g. two events or waves)
Source:R/compare.R
compare_values.RdJoins a current and a previous table on a key column and computes the
difference of a metric – for example feature performance from two
ipm_model() outputs, or pct from two calc_percentage() tables for two
events. The result feeds straight into plot_diff().
Value
A tibble with the key column, previous, current
and difference (current - previous).
Details
The join is a left join keyed on by with previous on the left, so the row
set follows the previous period and difference is current - previous (a
positive number means it went up). Keys present only in current are dropped;
keys missing from current get an NA difference. The inputs are deliberately
generic two-column-or-more tables, so the same function compares feature
performance from two ipm_model() runs, pct from two calc_percentage()
tables for two events, or any other keyed metric.
See also
plot_diff(), ipm_model(), calc_percentage().
Other compare:
plot_diff()
Examples
a <- data.frame(feature = c("price", "quality"), performance = c(3.1, 4.2))
b <- data.frame(feature = c("price", "quality"), performance = c(2.8, 4.4))
compare_values(current = b, previous = a)
#> # A tibble: 2 × 4
#> feature previous current difference
#> <chr> <dbl> <dbl> <dbl>
#> 1 price 3.1 2.8 -0.300
#> 2 quality 4.2 4.4 0.200