The number of Wynton users over time

users_over_time(file = NULL, since = "2017-01-01")

Arguments

file

A file with a single column of signup dates, or NULL. If NULL, then the Wynton LDAP server is queried.

since

Drop signup dates prior to this date.

Value

A tibble::tibble with columns date and total, total the cumulative sum based on date occurances.

Examples

library(dplyr)
#> 
#> Attaching package: ‘dplyr’
#> The following objects are masked from ‘package:stats’:
#> 
#>     filter, lag
#> The following objects are masked from ‘package:base’:
#> 
#>     intersect, setdiff, setequal, union

pathname <- system.file("exdata", "ldap_wynton_dates.txt", package = "wyntonquery")

signups <- users_over_time(pathname)
print(head(signups))
#> # A tibble: 6 × 2
#>   date       total
#>   <date>     <int>
#> 1 2017-02-21    17
#> 2 2017-04-20    18
#> 3 2017-04-25    19
#> 4 2017-05-23    20
#> 5 2017-07-04    21
#> 6 2017-07-13    22
print(tail(signups))
#> # A tibble: 6 × 2
#>   date       total
#>   <date>     <int>
#> 1 2024-04-26  1281
#> 2 2024-04-27  1282
#> 3 2024-04-27  1283
#> 4 2024-05-01  1284
#> 5 2024-05-01  1285
#> 6 2024-05-01  1286

## Summarize by year and month
signups <- mutate(signups, year = format(date, "%Y"))

## Signups per calendar year
signups <- mutate(signups, month = format(date, "%m"))
signups <- group_by(signups, year)
signups_per_year <- count(signups, name = "change")
signups_end_of_year <- filter(signups, date == max(date), total == max(total))
signups_per_year <- left_join(signups_per_year, signups_end_of_year)
#> Joining with `by = join_by(year)`
signups_per_year <- select(signups_per_year, year, change, total, per = date)
print(signups_per_year, n = Inf)
#> # A tibble: 8 × 4
#> # Groups:   year [8]
#>   year  change total per       
#>   <chr>  <int> <int> <date>    
#> 1 2017      27    43 2017-12-12
#> 2 2018      35    78 2018-12-21
#> 3 2019     113   191 2019-12-18
#> 4 2020     153   344 2020-12-22
#> 5 2021     158   502 2021-12-18
#> 6 2022     236   738 2022-12-23
#> 7 2023     372  1110 2023-12-27
#> 8 2024     176  1286 2024-05-01

## Signups per calendar month
signups <- group_by(signups, year, month)
signups_per_month <- count(signups, name = "change")
signups_end_of_month <- filter(signups, date == max(date), total == max(total))
signups_per_month <- left_join(signups_per_month, signups_end_of_month)
#> Joining with `by = join_by(year, month)`
signups_per_month <- select(signups_per_month, year, month, change, total, per = date)
print(signups_per_month, n = Inf)
#> # A tibble: 84 × 5
#> # Groups:   year, month [84]
#>    year  month change total per       
#>    <chr> <chr>  <int> <int> <date>    
#>  1 2017  02         1    17 2017-02-21
#>  2 2017  04         2    19 2017-04-25
#>  3 2017  05         1    20 2017-05-23
#>  4 2017  07         3    23 2017-07-19
#>  5 2017  08         3    26 2017-08-15
#>  6 2017  09         2    28 2017-09-22
#>  7 2017  10         5    33 2017-10-26
#>  8 2017  11         8    41 2017-11-30
#>  9 2017  12         2    43 2017-12-12
#> 10 2018  01         1    44 2018-01-16
#> 11 2018  02         6    50 2018-02-26
#> 12 2018  03         3    53 2018-03-29
#> 13 2018  05         4    57 2018-05-16
#> 14 2018  07         3    60 2018-07-20
#> 15 2018  08         9    69 2018-08-30
#> 16 2018  09         3    72 2018-09-07
#> 17 2018  10         2    74 2018-10-12
#> 18 2018  11         3    77 2018-11-30
#> 19 2018  12         1    78 2018-12-21
#> 20 2019  01         5    83 2019-01-17
#> 21 2019  02        10    93 2019-02-21
#> 22 2019  03        16   109 2019-03-22
#> 23 2019  04        13   122 2019-04-30
#> 24 2019  05         7   129 2019-05-28
#> 25 2019  06         6   135 2019-06-30
#> 26 2019  07        10   145 2019-07-29
#> 27 2019  08         6   151 2019-08-31
#> 28 2019  09        19   170 2019-09-28
#> 29 2019  10         7   177 2019-10-31
#> 30 2019  11         6   183 2019-11-26
#> 31 2019  12         8   191 2019-12-18
#> 32 2020  01        10   201 2020-01-29
#> 33 2020  02        11   212 2020-02-29
#> 34 2020  03         9   221 2020-03-25
#> 35 2020  04        14   235 2020-04-30
#> 36 2020  05        16   251 2020-05-29
#> 37 2020  06         5   256 2020-06-22
#> 38 2020  07        12   268 2020-07-29
#> 39 2020  08        20   288 2020-08-31
#> 40 2020  09        19   307 2020-09-29
#> 41 2020  10        15   322 2020-10-30
#> 42 2020  11        14   336 2020-11-19
#> 43 2020  12         8   344 2020-12-22
#> 44 2021  01         9   353 2021-01-28
#> 45 2021  02        13   366 2021-02-26
#> 46 2021  03        13   379 2021-03-25
#> 47 2021  04         9   388 2021-04-27
#> 48 2021  05         8   396 2021-05-21
#> 49 2021  06        12   408 2021-06-30
#> 50 2021  07         6   414 2021-07-27
#> 51 2021  08        19   433 2021-08-30
#> 52 2021  09        23   456 2021-09-30
#> 53 2021  10        18   474 2021-10-27
#> 54 2021  11        15   489 2021-11-25
#> 55 2021  12        13   502 2021-12-18
#> 56 2022  01        18   520 2022-01-30
#> 57 2022  02        13   533 2022-02-26
#> 58 2022  03        23   556 2022-03-31
#> 59 2022  04        17   573 2022-04-27
#> 60 2022  05        13   586 2022-05-27
#> 61 2022  06        20   606 2022-06-29
#> 62 2022  07        24   630 2022-07-27
#> 63 2022  08        27   657 2022-08-31
#> 64 2022  09        35   692 2022-09-24
#> 65 2022  10        19   711 2022-10-26
#> 66 2022  11        20   731 2022-11-29
#> 67 2022  12         7   738 2022-12-23
#> 68 2023  01        21   759 2023-01-31
#> 69 2023  02        17   776 2023-02-28
#> 70 2023  03        16   792 2023-03-24
#> 71 2023  04        17   809 2023-04-28
#> 72 2023  05        22   831 2023-05-13
#> 73 2023  06        41   872 2023-06-30
#> 74 2023  07        40   912 2023-07-29
#> 75 2023  08        41   953 2023-08-29
#> 76 2023  09        75  1028 2023-09-30
#> 77 2023  10        27  1055 2023-10-27
#> 78 2023  11        31  1086 2023-11-29
#> 79 2023  12        24  1110 2023-12-27
#> 80 2024  01        45  1155 2024-01-31
#> 81 2024  02        43  1198 2024-02-29
#> 82 2024  03        36  1234 2024-03-29
#> 83 2024  04        49  1283 2024-04-27
#> 84 2024  05         3  1286 2024-05-01


if (require("ggplot2", quietly = TRUE)) {
  gg <- ggplot(signups, aes(date, total)) + geom_line(linewidth = 2.0)
  gg <- gg + xlab("") + ylab("Number of users")
  gg <- gg + theme(text = element_text(size = 20))
  print(gg)
}