You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In business and financial analytics, the **ABC classification** method is widely used to categorize items, customers, or other groups according to their relative contribution to a total metric.
18
+
The `abc()` function provides an easy way to classify a group's member by their relative contribution of either their **transaction counts** or the sum of a **numeric variable** such as sales margin or revenue.
18
19
19
-
The `abc()` function provides a flexible and robust way to perform ABC segmentation, either based on **transaction counts** or the sum of a **numeric variable** such as sales margin or revenue.
20
-
21
-
### Function Purpose
22
-
23
-
`abc()`:
24
-
25
-
- Segments a dataset into categories (A, B, C, etc.) based on cumulative contribution.
26
-
- Allows for **custom break points** (e.g., top 10% = A, next 40% = B, etc.).
27
-
- Works on both **grouped tibbles** and **database-backed objects**.
28
-
- Returns a **segment object**, which is processed by `calculate()` to produce a table of results.
20
+
- Allows for **custom break points** (e.g., top 10% = A, next 40% = B, etc.)
21
+
- Works on both **tibbles** and **database objects**
22
+
- Returns a **segment object**, which is processed by `calculate()` to produce a table of results
29
23
30
24
### How It Works
31
25
32
-
> `fpaR::abc()` requires a grouped tibble or lazy DBI object using `dplyr::group_by()` to specify the groups that drive the contribution
26
+
> `abc()` requires a grouped tibble or lazy DBI object using `dplyr::group_by()` to specify the group composition that drives the contribution
33
27
34
28
**Value Capture**
35
29
36
-
- If `.value` is provided, the the column is aggregate per group; otherwise, it counts rows.
30
+
- If `.value` is provided, then that column is aggregate per group member; otherwise, it counts rows
37
31
38
32
**Category Values**
39
33
40
-
- Provide the break points break points that are used to set the cumulative categories. Each break point will get a letter category starting with 'A'
34
+
- Provide the break points that are used to set the cumulative categories
35
+
- Each break point will get a letter category starting with 'A'
41
36
- If you want to see the stores that make up the top 40% of revenue follow by top 70% and then 90% you should put in `c(0.4,.7,.9,1)`
42
37
43
38
@@ -74,15 +69,20 @@ contoso::sales |>
74
69
)
75
70
```
76
71
77
-
The function returns a **segment object**. Use `calculate()` to generate the ABC classification table:
72
+
The function returns a **segment object**
73
+
74
+
- This will summarize the series of actions and meta information about your data
75
+
- Use `calculate()` to generate the ABC classification table
76
+
- This will return a duckdb DBI object use `dplyr::collect()` to return a tibble
78
77
79
78
```{r}
80
-
#| label: var
79
+
#| label: calculate
81
80
#| echo: true
82
81
#| eval: false
83
82
#| warning: false
84
83
#| message: false
85
84
#| include: true
85
+
86
86
contoso::sales |>
87
87
dplyr::group_by(store_key) |>
88
88
fpaR::abc(
@@ -122,7 +122,7 @@ This table contains grouped data with various metrics, highlighting the contribu
122
122
123
123
### Understanding the Results
124
124
125
-
- Store 540 has a margin of $7,812.11 ("ABC Margin"), which accounts for about 4% ("prop_total") of the total margin across all stores
125
+
-Store 540 has a margin of $7,812.11 ("ABC Margin"), which accounts for about 4% ("prop_total") of the total margin across all stores
126
126
127
127
- The "cum_sum" column tracks the running total of values (e.g., revenue or count) for each store, showing the cumulative sum up to that row
128
128
@@ -136,7 +136,7 @@ This table contains grouped data with various metrics, highlighting the contribu
136
136
137
137
- The category_value and category_name columns define the breakpoints you provided, assigning stores to categories (e.g., 'A', 'B', 'C') based on their cumulative contribution
0 commit comments