Skip to content

Commit 096b6aa

Browse files
committed
updated documentation, most are good shape except cohorts and calendar_types. non-standard calendar still needs testing. estimate 2 committed days to close this out completely. priority should be to close out documentation and (0.5 days) test calendar types (1.5 days). then need to move this over to fpa with clean version and can open up enhacements down the road
1 parent 4bd3abd commit 096b6aa

33 files changed

+143
-7034
lines changed

R/utils-misc.R

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,6 @@ print_actions_steps <- function(x){
221221

222222
augment_standard_calendar_tbl <- function(.data,.date){
223223

224-
lubridate::days
225224
# create attibutes
226225
out <- .data |>
227226
dplyr::mutate(
@@ -316,7 +315,7 @@ augment_standard_calendar_dbi <- function(.data,.date){
316315

317316
date_vec <- rlang::as_label(.date)
318317

319-
# out <-
318+
out <-
320319
.data |>
321320
dplyr::mutate(
322321
year_start_date=lubridate::floor_date({{.date}},unit = "year")
@@ -351,6 +350,8 @@ augment_standard_calendar_dbi <- function(.data,.date){
351350
dplyr::across(dplyr::contains("date"),\(x) as.Date(x))
352351
)
353352

353+
return(out)
354+
354355
}
355356

356357

@@ -419,6 +420,8 @@ augment_standard_calendar <- function(.data,.date){
419420

420421
out <- augment_standard_calendar_dbi(.data = .data,.date = .date_var)
421422

423+
return(out)
424+
422425

423426
}
424427

@@ -427,11 +430,11 @@ augment_standard_calendar <- function(.data,.date){
427430

428431
out <- augment_standard_calendar_tbl(.data = .data,.date = !!.date_var)
429432

433+
return(out)
430434
}
431435

432436

433437

434-
435438
}
436439

437440

@@ -630,7 +633,6 @@ augment_non_standard_calendar <- function(.data,pattern){
630633
}
631634

632635

633-
634636
utils::globalVariables(
635637
c(
636638
"desc",

_pkgdown.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,4 @@
5858
- yoy # year-over-year (full)
5959
- yoytd # YTD vs prior YTD
6060
- ytdopy # YTD over previous full year
61+

renv.lock

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@
213213
},
214214
"S7": {
215215
"Package": "S7",
216-
"Version": "0.2.0",
216+
"Version": "0.2.1",
217217
"Source": "Repository",
218218
"Title": "An Object Oriented System Meant to Become a Successor to S3 and S4",
219219
"Authors@R": "c( person(\"Object-Oriented Programming Working Group\", role = \"cph\"), person(\"Davis\", \"Vaughan\", role = \"aut\"), person(\"Jim\", \"Hester\", role = \"aut\", comment = c(ORCID = \"0000-0002-2739-7082\")), person(\"Tomasz\", \"Kalinowski\", role = \"aut\"), person(\"Will\", \"Landau\", role = \"aut\"), person(\"Michael\", \"Lawrence\", role = \"aut\"), person(\"Martin\", \"Maechler\", role = \"aut\", comment = c(ORCID = \"0000-0002-8685-9910\")), person(\"Luke\", \"Tierney\", role = \"aut\"), person(\"Hadley\", \"Wickham\", , \"[email protected]\", role = c(\"aut\", \"cre\"), comment = c(ORCID = \"0000-0003-4757-117X\")) )",
@@ -244,9 +244,9 @@
244244
"Config/testthat/parallel": "TRUE",
245245
"Config/testthat/start-first": "external-generic",
246246
"Encoding": "UTF-8",
247-
"RoxygenNote": "7.3.2",
247+
"RoxygenNote": "7.3.3",
248248
"NeedsCompilation": "yes",
249-
"Author": "Object-Oriented Programming Working Group [cph], Davis Vaughan [aut], Jim Hester [aut] (<https://orcid.org/0000-0002-2739-7082>), Tomasz Kalinowski [aut], Will Landau [aut], Michael Lawrence [aut], Martin Maechler [aut] (<https://orcid.org/0000-0002-8685-9910>), Luke Tierney [aut], Hadley Wickham [aut, cre] (<https://orcid.org/0000-0003-4757-117X>)",
249+
"Author": "Object-Oriented Programming Working Group [cph], Davis Vaughan [aut], Jim Hester [aut] (ORCID: <https://orcid.org/0000-0002-2739-7082>), Tomasz Kalinowski [aut], Will Landau [aut], Michael Lawrence [aut], Martin Maechler [aut] (ORCID: <https://orcid.org/0000-0002-8685-9910>), Luke Tierney [aut], Hadley Wickham [aut, cre] (ORCID: <https://orcid.org/0000-0003-4757-117X>)",
250250
"Maintainer": "Hadley Wickham <[email protected]>",
251251
"Repository": "CRAN"
252252
},
@@ -1537,7 +1537,7 @@
15371537
},
15381538
"duckdb": {
15391539
"Package": "duckdb",
1540-
"Version": "1.4.1.9006",
1540+
"Version": "1.4.2.9003",
15411541
"Source": "GitHub",
15421542
"Title": "DBI Package for the DuckDB Database Management System",
15431543
"Authors@R": "c( person(\"Hannes\", \"Mühleisen\", , \"[email protected]\", role = \"aut\", comment = c(ORCID = \"0000-0001-8552-0029\")), person(\"Mark\", \"Raasveldt\", , \"[email protected]\", role = \"aut\", comment = c(ORCID = \"0000-0001-5005-6844\")), person(\"Kirill\", \"Müller\", , \"[email protected]\", role = \"cre\", comment = c(ORCID = \"0000-0002-1416-3412\")), person(\"Stichting DuckDB Foundation\", role = \"cph\"), person(\"Apache Software Foundation\", role = \"cph\"), person(\"PostgreSQL Global Development Group\", role = \"cph\"), person(\"The Regents of the University of California\", role = \"cph\"), person(\"Cameron Desrochers\", role = \"cph\"), person(\"Victor Zverovich\", role = \"cph\"), person(\"RAD Game Tools\", role = \"cph\"), person(\"Valve Software\", role = \"cph\"), person(\"Rich Geldreich\", role = \"cph\"), person(\"Tenacious Software LLC\", role = \"cph\"), person(\"The RE2 Authors\", role = \"cph\"), person(\"Google Inc.\", role = \"cph\"), person(\"Facebook Inc.\", role = \"cph\"), person(\"Steven G. Johnson\", role = \"cph\"), person(\"Jiahao Chen\", role = \"cph\"), person(\"Tony Kelman\", role = \"cph\"), person(\"Jonas Fonseca\", role = \"cph\"), person(\"Lukas Fittl\", role = \"cph\"), person(\"Salvatore Sanfilippo\", role = \"cph\"), person(\"Art.sy, Inc.\", role = \"cph\"), person(\"Oran Agra\", role = \"cph\"), person(\"Redis Labs, Inc.\", role = \"cph\"), person(\"Melissa O'Neill\", role = \"cph\"), person(\"PCG Project contributors\", role = \"cph\") )",
@@ -1583,9 +1583,8 @@
15831583
"RemoteHost": "api.github.com",
15841584
"RemoteRepo": "duckdb-r",
15851585
"RemoteUsername": "duckdb",
1586-
"RemotePkgRef": "duckdb/duckdb-r",
15871586
"RemoteRef": "HEAD",
1588-
"RemoteSha": "e95be413e22c3017989177f069542964b4189e1c",
1587+
"RemoteSha": "0ed289d9ca6513dabe081e2cb0556046503243d6",
15891588
"NeedsCompilation": "yes",
15901589
"Author": "Hannes Mühleisen [aut] (ORCID: <https://orcid.org/0000-0001-8552-0029>), Mark Raasveldt [aut] (ORCID: <https://orcid.org/0000-0001-5005-6844>), Kirill Müller [cre] (ORCID: <https://orcid.org/0000-0002-1416-3412>), Stichting DuckDB Foundation [cph], Apache Software Foundation [cph], PostgreSQL Global Development Group [cph], The Regents of the University of California [cph], Cameron Desrochers [cph], Victor Zverovich [cph], RAD Game Tools [cph], Valve Software [cph], Rich Geldreich [cph], Tenacious Software LLC [cph], The RE2 Authors [cph], Google Inc. [cph], Facebook Inc. [cph], Steven G. Johnson [cph], Jiahao Chen [cph], Tony Kelman [cph], Jonas Fonseca [cph], Lukas Fittl [cph], Salvatore Sanfilippo [cph], Art.sy, Inc. [cph], Oran Agra [cph], Redis Labs, Inc. [cph], Melissa O'Neill [cph], PCG Project contributors [cph]",
15911590
"Maintainer": "Kirill Müller <[email protected]>"
@@ -2704,7 +2703,7 @@
27042703
},
27052704
"janitor": {
27062705
"Package": "janitor",
2707-
"Version": "2.2.0",
2706+
"Version": "2.2.1",
27082707
"Source": "Repository",
27092708
"Title": "Simple Tools for Examining and Cleaning Dirty Data",
27102709
"Authors@R": "c(person(\"Sam\", \"Firke\", email = \"[email protected]\", role = c(\"aut\", \"cre\")), person(\"Bill\", \"Denney\", email = \"[email protected]\", role = \"ctb\"), person(\"Chris\", \"Haid\", email = \"[email protected]\", role = \"ctb\"), person(\"Ryan\", \"Knight\", email = \"[email protected]\", role = \"ctb\"), person(\"Malte\", \"Grosser\", email = \"[email protected]\", role = \"ctb\"), person(\"Jonathan\", \"Zadra\", email = \"[email protected]\", role = \"ctb\"))",
@@ -4968,7 +4967,7 @@
49684967
},
49694968
"stringr": {
49704969
"Package": "stringr",
4971-
"Version": "1.5.2",
4970+
"Version": "1.6.0",
49724971
"Source": "Repository",
49734972
"Title": "Simple, Consistent Wrappers for Common String Operations",
49744973
"Authors@R": "c( person(\"Hadley\", \"Wickham\", , \"[email protected]\", role = c(\"aut\", \"cre\", \"cph\")), person(\"Posit Software, PBC\", role = c(\"cph\", \"fnd\")) )",
@@ -4977,7 +4976,7 @@
49774976
"URL": "https://stringr.tidyverse.org, https://github.com/tidyverse/stringr",
49784977
"BugReports": "https://github.com/tidyverse/stringr/issues",
49794978
"Depends": [
4980-
"R (>= 3.6)"
4979+
"R (>= 4.1.0)"
49814980
],
49824981
"Imports": [
49834982
"cli",
@@ -5001,10 +5000,11 @@
50015000
],
50025001
"VignetteBuilder": "knitr",
50035002
"Config/Needs/website": "tidyverse/tidytemplate",
5003+
"Config/potools/style": "explicit",
50045004
"Config/testthat/edition": "3",
50055005
"Encoding": "UTF-8",
50065006
"LazyData": "true",
5007-
"RoxygenNote": "7.3.2",
5007+
"RoxygenNote": "7.3.3",
50085008
"NeedsCompilation": "no",
50095009
"Author": "Hadley Wickham [aut, cre, cph], Posit Software, PBC [cph, fnd]",
50105010
"Maintainer": "Hadley Wickham <[email protected]>",

vignettes/articles/abc.qmd

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,15 @@ subtitle: "How to use classification strategies to focus your analysis"
88
#| echo: false
99
1010
library(fpaR)
11-
1211
quarto::write_yaml_metadata_block(
1312
date=format(Sys.Date())
1413
)
1514
```
1615

1716

18-
### Introduction
17+
In business and financial analytics, the **ABC classification** method is widely used to categorize items, customers, or any group members according to their relative contribution to a total metric.
1918

20-
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.
21-
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.
19+
The `abc()` function applies this method by ranking group members according to either transaction counts or the sum of a numeric variable (e.g., revenue, margin):
2220

2321
- Allows for **custom break points** (e.g., top 10% = A, next 40% = B, etc.)
2422
- Works on both **tibbles** and **database objects**
@@ -56,6 +54,13 @@ tibble::tibble(
5654
```
5755

5856

57+
When you execute `abc()`, your console will return a `segment_abc` object displaying a custom print message:
58+
59+
- A summary of the function's actions
60+
- Details the category break points and labels
61+
- Describes the main transformation steps and columns that are referenced
62+
- Lists out possible next actions
63+
5964

6065
```{r}
6166
#| label: abc-example
@@ -72,11 +77,7 @@ contoso::sales |>
7277
)
7378
```
7479

75-
The function returns a **segment object**
76-
77-
- This will summarize the series of actions and meta information about your data
78-
- Use `calculate()` to generate the ABC classification table
79-
- This will return a duckdb DBI object use `dplyr::collect()` to return a tibble
80+
Use `calculate()` to generate the ABC classification table in a lazy DBI object. Use `dplyr::collect()` to return a tibble.
8081

8182
```{r}
8283
#| label: calculate
@@ -116,7 +117,7 @@ contoso::sales |>
116117
fpaR::calculate() |>
117118
dplyr::collect() |>
118119
dplyr::arrange(row_id) |>
119-
head(10) |>
120+
head(10) |>
120121
tinytable::tt()
121122
```
122123

vignettes/articles/calendar_types.qmd

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ quarto::write_yaml_metadata_block(
1414

1515
### Introduction
1616

17-
In many fpaR functions, you will see a reference to a calendar_type argument which may confuse most of you, isn't there only one type of calendar?
17+
In many fpaR functions, you will see a reference to a `calendar_type` argument which may confuse most of you, isn't there only one type of calendar?
1818

1919
To accomodate the uniqueness of some industries, financial planning analysis will often involve two calendar systems:
2020

2121
1. **Standard Calendar**
22-
2. **5-5-4 Calendar**
22+
2. **Non-standard Calendar** such as `5-4-4`, `4-4-5` or `4-5-4`
2323

2424
This vignette explains the differences between these calendars and their typical use cases.
2525

@@ -29,7 +29,8 @@ This is your "typical" calendar also known as a conventional Gregorian calendar:
2929

3030
- 12 months of varying lengths (28–31 days)
3131
- 52 weeks per year (sometimes 53 in leap years)
32-
- Months are uneven in length, which can cause challenges in period-over-period comparison
32+
- 7 days in a week
33+
- 365 days in a year (except in the leap years)
3334

3435
For most of your analysis this is most likely the calendar "type" that you need to follow
3536
**Example:**
@@ -49,25 +50,25 @@ The primary disadvantage of this calendar is that when you try to compare a metr
4950
This can lead to misleading conclusions that revenue is increasing or decreasing
5051

5152

52-
### 5-5-4 Calendar
53+
### 5-4-4 Calendar
5354

54-
The **5-5-4 calendar** is commonly used in retail designed to simplify period-over-period comparisons which a standard calendar introduces
55+
The **5-4-4 calendar** is commonly used in retail designed to simplify period-over-period comparisons which a standard calendar introduces
5556

56-
- Each quarter has **13 weeks**, divided into three periods: 5 weeks, 5 weeks, 4 weeks
57+
- Each quarter has **13 weeks**, divided into three periods: 5 weeks, 4 weeks, 4 weeks
5758
- Each month in the quarter has a fixed number of weeks (rather than days)
5859
- Some years include a **53rd week** to align with the solar calendar
5960

60-
**Example of a Quarter in 5-5-4 Calendar:**
61+
**Example of a Quarter in 5-4-4 Calendar:**
6162

6263
| Period | Weeks |
6364
|--------|------|
6465
| Month 1 | 5 |
65-
| Month 2 | 5 |
66+
| Month 2 | 4 |
6667
| Month 3 | 4 |
6768

6869
### Comparison
6970

70-
| Feature | Standard Calendar | 5-5-4 Calendar |
71+
| Feature | Standard Calendar | 5-4-4 Calendar |
7172
|---------|-----------------|----------------|
7273
| Basis | Days in month | Weeks in period |
7374
| Month Length | Varies (28–31 days) | Fixed (4 or 5 weeks) |
@@ -77,7 +78,7 @@ The **5-5-4 calendar** is commonly used in retail designed to simplify period-ov
7778

7879
### How to reference in `fpaR` functions?
7980

80-
Where you see `calandar_type` argument in function you can either put in "standard" to get a traditional calendar or you can put "554" or "445" to get the alternative cealndar equivalents.
81+
Where you see `calandar_type` argument in function you can either put in "standard" to get a traditional calendar or you can put "544","454" or "445" to get the alternative calendar equivalents.
8182

8283
Under the hood `fpaR` will create and convert your calendar to right calendar types an the functions will correctly index of the new keys.
8384

vignettes/articles/calendar_types_files/libs/bootstrap/bootstrap-c45587a26a1df833d5e643ccce865553.min.css

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)