From dbac6dde86ee0baeb729531c57a55a85a2cbd0a0 Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 23 Dec 2024 13:22:47 +0100 Subject: [PATCH] fix --- R/data_xtabulate.R | 4 +- tests/testthat/_snaps/data_tabulate.md | 67 +------------------------- 2 files changed, 4 insertions(+), 67 deletions(-) diff --git a/R/data_xtabulate.R b/R/data_xtabulate.R index da7fde763..b06645e0e 100644 --- a/R/data_xtabulate.R +++ b/R/data_xtabulate.R @@ -229,7 +229,7 @@ print_html.datawizard_crosstab <- function(x, big_mark = NULL, ...) { # prepare table arguments fun_args <- list( - format(x, big_mark = big_mark, ...), + format(x, big_mark = big_mark, format = format, ...), caption = caption, format = format ) @@ -277,7 +277,7 @@ print_html.datawizard_crosstabs <- function(x, big_mark = NULL, ...) { .print_text_tables <- function(x, big_mark = NULL, format = "text", ...) { if (length(x) == 1) { - print(x[[1]], big_mark = big_mark, ...) + .print_text_table(x[[1]], big_mark = big_mark, format = format, ...) } else { x <- lapply(x, function(i) { # grouped data? if yes, add information on grouping factor diff --git a/tests/testthat/_snaps/data_tabulate.md b/tests/testthat/_snaps/data_tabulate.md index ffde63088..f284f4edd 100644 --- a/tests/testthat/_snaps/data_tabulate.md +++ b/tests/testthat/_snaps/data_tabulate.md @@ -311,7 +311,6 @@ | 5 (50.0%) | 4 (40.0%) | 1 (10.0%) | 10 ---------+------------+------------+-----------+------ Total | 45 | 50 | 5 | 100 - --- @@ -326,7 +325,6 @@ 3 | 4 (26.7%) | 11 (73.3%) | 15 ---------+------------+------------+------ Total | 40 | 46 | 86 - --- @@ -342,7 +340,6 @@ | 8 (57.1%) | 5 (35.7%) | 1 (7.1%) | 14 ---------+------------+------------+-----------+------ Total | 48 | 51 | 7 | 105 - --- @@ -357,7 +354,6 @@ 3 | 3 (21.4%) | 11 (78.6%) | 14 ---------+------------+------------+------ Total | 40 | 46 | 86 - --- @@ -372,7 +368,6 @@ | 5 (11.1%) | 4 (8.0%) | 1 (20.0%) | 10 ---------+------------+------------+-----------+------ Total | 45 | 50 | 5 | 100 - --- @@ -387,7 +382,6 @@ 3 | 4 (10.0%) | 11 (23.9%) | 15 ---------+------------+------------+------ Total | 40 | 46 | 86 - --- @@ -403,7 +397,6 @@ | 8 (16.7%) | 5 (9.8%) | 1 (14.3%) | 14 ---------+------------+------------+-----------+------ Total | 48 | 51 | 7 | 105 - --- @@ -418,62 +411,6 @@ 3 | 3 (7.5%) | 11 (23.9%) | 14 ---------+------------+------------+------ Total | 40 | 46 | 86 - - -# data_tabulate, cross tables, grouped df - - Code - print(data_tabulate(grp, "c172code", by = "e16sex", proportions = "row")) - Output - Grouped by e42dep (1) - - c172code | male | | Total - ---------+------------+------------+------ - 2 | 2 (100.0%) | 0 (0.0%) | 2 - | 0 (0%) | 0 (0%) | 0 - ---------+------------+------------+------ - Total | 2 | 0 | 2 - - Grouped by e42dep (2) - - c172code | male | female | | Total - ---------+-----------+-----------+-----------+------ - 2 | 2 (50.0%) | 2 (50.0%) | 0 (0.0%) | 4 - | 0 (0%) | 0 (0%) | 0 (0%) | 0 - ---------+-----------+-----------+-----------+------ - Total | 2 | 2 | 0 | 4 - - Grouped by e42dep (3) - - c172code | male | female | | Total - ---------+-----------+------------+-----------+------ - 1 | 2 (50.0%) | 2 (50.0%) | 0 (0.0%) | 4 - 2 | 4 (25.0%) | 11 (68.8%) | 1 (6.2%) | 16 - 3 | 1 (16.7%) | 5 (83.3%) | 0 (0.0%) | 6 - | 1 (50.0%) | 0 (0.0%) | 1 (50.0%) | 2 - ---------+-----------+------------+-----------+------ - Total | 8 | 18 | 2 | 28 - - Grouped by e42dep (4) - - c172code | male | female | | Total - ---------+------------+------------+-----------+------ - 1 | 3 (75.0%) | 0 (0.0%) | 1 (25.0%) | 4 - 2 | 23 (54.8%) | 18 (42.9%) | 1 (2.4%) | 42 - 3 | 3 (30.0%) | 6 (60.0%) | 1 (10.0%) | 10 - | 3 (42.9%) | 4 (57.1%) | 0 (0.0%) | 7 - ---------+------------+------------+-----------+------ - Total | 32 | 28 | 3 | 63 - - Grouped by e42dep (NA) - - c172code | male | female | | Total - ---------+------------+------------+------------+------ - 2 | 0 (0.0%) | 2 (100.0%) | 0 (0.0%) | 2 - | 1 (100.0%) | 0 (0.0%) | 0 (0.0%) | 1 - ---------+------------+------------+------------+------ - Total | 1 | 2 | 0 | 3 - # data_tabulate, cross tables, markdown @@ -485,7 +422,7 @@ [3] "|1 | 5 (5.0%)| 2 (2.0%)|1 (1.0%) | 8|" [4] "|2 | 31 (31.0%)| 33 (33.0%)|2 (2.0%) | 66|" [5] "|3 | 4 (4.0%)| 11 (11.0%)|1 (1.0%) | 16|" - [6] "| | 5 (5.0%)| 4 (4.0%)|1 (1.0%) | 10|" + [6] "|(NA) | 5 (5.0%)| 4 (4.0%)|1 (1.0%) | 10|" [7] "| | | | | |" [8] "|Total | 45| 50| 5 | 100|" attr(,"format") @@ -522,7 +459,7 @@ [3] "|1 | 5 (4.8%)| 3 (2.9%)|2 (1.9%) | 10|" [4] "|2 | 32 (30.5%)| 32 (30.5%)|3 (2.9%) | 67|" [5] "|3 | 3 (2.9%)| 11 (10.5%)|1 (1.0%) | 15|" - [6] "| | 8 (7.6%)| 5 (4.8%)|1 (1.0%) | 14|" + [6] "|(NA) | 8 (7.6%)| 5 (4.8%)|1 (1.0%) | 14|" [7] "| | | | | |" [8] "|Total | 48| 51| 7 | 105|" attr(,"format")