format_result: Format estimated metrics for input to Dashboard

Description Usage Arguments See Also Examples

View source: R/dashboard.R

Description

This function expects a data frame produced by an salic estimation function ( est_part, est_recruit, est_churn). It returns a data frame with additional formatting that allows stacking all results into a single table.

Usage

1
2
format_result(df, timeframe, group, rename_input = c("category", "year",
  "value"))

Arguments

df

data frame: Input table (3 variables) with estimated metrics

timeframe

character: value to store in the 'timeframe' variable of the output (e.g, 'full-year', 'mid-year')

group

character: value to sore in the 'group' variable of the output (e.g., 'all_sports', 'fish', 'hunt')

rename_input

character: generic names for input variables as they will appear in the output

See Also

Salic Function Reference: salic

Other dashboard functions: check_threshold, est_churn, est_part, scaleup_part

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
library(dplyr)
data(metrics)

# format a table
metrics$participants$res

x <- format_result(metrics$participants$res, "full-year", "all_sports")
x

# combine formatted tables
y <- format_result(metrics$participants$tot, "full-year", "all_sports")
bind_rows(y, x)

# apply formatting across all segments
x <- lapply(metrics$participants, function(x) format_result(x, "full-year", "sports"))
bind_rows(x)
   
# apply across all metrics & segments
bind_rows(
    lapply(metrics$participants, function(x) format_result(x, "full-year", "sports")),
    lapply(metrics$recruits, function(x) format_result(x, "full-year", "sports")),
    lapply(metrics$churn, function(x) format_result(x, "full-year", "sports"))
)

southwick-associates/salic documentation built on Nov. 5, 2019, 9:13 a.m.