tests/testthat/_snaps/xlr_n_percent.md

xlr_n_percent.format prints the way we want it

Code
  xlr_n_percent(n = 1:100, pct = (1:100) / 100)
Output
  <xlr_n_percent[100]>
    [1] 1 (1%)     2 (2%)     3 (3%)     4 (4%)     5 (5%)     6 (6%)    
    [7] 7 (7%)     8 (8%)     9 (9%)     10 (10%)   11 (11%)   12 (12%)  
   [13] 13 (13%)   14 (14%)   15 (15%)   16 (16%)   17 (17%)   18 (18%)  
   [19] 19 (19%)   20 (20%)   21 (21%)   22 (22%)   23 (23%)   24 (24%)  
   [25] 25 (25%)   26 (26%)   27 (27%)   28 (28%)   29 (29%)   30 (30%)  
   [31] 31 (31%)   32 (32%)   33 (33%)   34 (34%)   35 (35%)   36 (36%)  
   [37] 37 (37%)   38 (38%)   39 (39%)   40 (40%)   41 (41%)   42 (42%)  
   [43] 43 (43%)   44 (44%)   45 (45%)   46 (46%)   47 (47%)   48 (48%)  
   [49] 49 (49%)   50 (50%)   51 (51%)   52 (52%)   53 (53%)   54 (54%)  
   [55] 55 (55%)   56 (56%)   57 (57%)   58 (58%)   59 (59%)   60 (60%)  
   [61] 61 (61%)   62 (62%)   63 (63%)   64 (64%)   65 (65%)   66 (66%)  
   [67] 67 (67%)   68 (68%)   69 (69%)   70 (70%)   71 (71%)   72 (72%)  
   [73] 73 (73%)   74 (74%)   75 (75%)   76 (76%)   77 (77%)   78 (78%)  
   [79] 79 (79%)   80 (80%)   81 (81%)   82 (82%)   83 (83%)   84 (84%)  
   [85] 85 (85%)   86 (86%)   87 (87%)   88 (88%)   89 (89%)   90 (90%)  
   [91] 91 (91%)   92 (92%)   93 (93%)   94 (94%)   95 (95%)   96 (96%)  
   [97] 97 (97%)   98 (98%)   99 (99%)   100 (100%)
Code
  xlr_n_percent(n = 0:99, pct = (0:99) / 100, dp = 2)
Output
  <xlr_n_percent[100]>
    [1] 0 (0.00%)   1 (1.00%)   2 (2.00%)   3 (3.00%)   4 (4.00%)   5 (5.00%)  
    [7] 6 (6.00%)   7 (7.00%)   8 (8.00%)   9 (9.00%)   10 (10.00%) 11 (11.00%)
   [13] 12 (12.00%) 13 (13.00%) 14 (14.00%) 15 (15.00%) 16 (16.00%) 17 (17.00%)
   [19] 18 (18.00%) 19 (19.00%) 20 (20.00%) 21 (21.00%) 22 (22.00%) 23 (23.00%)
   [25] 24 (24.00%) 25 (25.00%) 26 (26.00%) 27 (27.00%) 28 (28.00%) 29 (29.00%)
   [31] 30 (30.00%) 31 (31.00%) 32 (32.00%) 33 (33.00%) 34 (34.00%) 35 (35.00%)
   [37] 36 (36.00%) 37 (37.00%) 38 (38.00%) 39 (39.00%) 40 (40.00%) 41 (41.00%)
   [43] 42 (42.00%) 43 (43.00%) 44 (44.00%) 45 (45.00%) 46 (46.00%) 47 (47.00%)
   [49] 48 (48.00%) 49 (49.00%) 50 (50.00%) 51 (51.00%) 52 (52.00%) 53 (53.00%)
   [55] 54 (54.00%) 55 (55.00%) 56 (56.00%) 57 (57.00%) 58 (58.00%) 59 (59.00%)
   [61] 60 (60.00%) 61 (61.00%) 62 (62.00%) 63 (63.00%) 64 (64.00%) 65 (65.00%)
   [67] 66 (66.00%) 67 (67.00%) 68 (68.00%) 69 (69.00%) 70 (70.00%) 71 (71.00%)
   [73] 72 (72.00%) 73 (73.00%) 74 (74.00%) 75 (75.00%) 76 (76.00%) 77 (77.00%)
   [79] 78 (78.00%) 79 (79.00%) 80 (80.00%) 81 (81.00%) 82 (82.00%) 83 (83.00%)
   [85] 84 (84.00%) 85 (85.00%) 86 (86.00%) 87 (87.00%) 88 (88.00%) 89 (89.00%)
   [91] 90 (90.00%) 91 (91.00%) 92 (92.00%) 93 (93.00%) 94 (94.00%) 95 (95.00%)
   [97] 96 (96.00%) 97 (97.00%) 98 (98.00%) 99 (99.00%)
Code
  tibble::tibble(test = xlr_n_percent(n = 0:99, pct = (0:99) / 100, dp = 2))
Output
  # A tibble: 100 x 1
          test
     <x_n_pct>
   1 0 (0.00%)
   2 1 (1.00%)
   3 2 (2.00%)
   4 3 (3.00%)
   5 4 (4.00%)
   6 5 (5.00%)
   7 6 (6.00%)
   8 7 (7.00%)
   9 8 (8.00%)
  10 9 (9.00%)
  # i 90 more rows

vec_ptype2.xlr_n_percent.xlr_n_percent raises warning when things don't match

Code
  c(xlr_n_percent(n = 1, pct = 0.5), xlr_n_percent(n = 1, pct = 0.5, dp = 3))
Condition
  Warning:
  Percent attributes ("dp", or "style) do not match, taking the attributes from the left-hand side.
Output
  <xlr_n_percent[2]>
  [1] 1 (50%) 1 (50%)

vec_arith.xlr_n_percent.xlr_n_percent raises warning when things don't match

Code
  xlr_n_percent(n = 1, pct = 0.5) + xlr_n_percent(n = 1, pct = 0.5, dp = 3)
Condition
  Warning:
  Percent attributes ("dp", or "style) do not match, taking the attributes from the left-hand side.
Output
  <xlr_n_percent[1]>
  [1] 2 (100%)


Try the xlr package in your browser

Any scripts or data that you put into this service are public.

xlr documentation built on Jan. 14, 2026, 9:09 a.m.