# the values can be manually entered
compare_values(10, 8) |> head(2)
# percent difference (10-8)/8
compare_values(10, 8)$delta_p
# trend_phrases returns an object called trend if nothing is passed
compare_values(10, 8)$trend
# or if one argument is passed using trend_terms()
compare_values(10, 8, trend_phrases = trend_terms(more = "higher"))$trend
# if a named list is used, the objects are called by their names
compare_values(
10, 8,
trend_phrases = list(
more = trend_terms(),
higher = trend_terms("higher", "lower")
)
)$higher
# a phrase about the comparison can be edited by providing glue syntax
# 'c' = the 'compare' value, 'r' = 'reference'
compare_values(10, 8, orig_values = "{x} to {y} people")$orig_values
# you can also adjust the rounding, although the default is 1
compare_values(0.1234, 0.4321)$orig_values
compare_values(0.1234, 0.4321, n_decimal = 3)$orig_values
# or add a multiplier
compare_values(0.1234, 0.4321, multiplier = 100)$orig_values
Run the code above in your browser using DataLab