From 14d16d81e31858eeff5735634097111d2a6098bf Mon Sep 17 00:00:00 2001 From: Daniel Date: Sun, 3 Nov 2024 10:34:10 +0100 Subject: [PATCH] update tests --- DESCRIPTION | 2 +- tests/testthat/_snaps/data_codebook.md | 177 +++++++++---------------- tests/testthat/test-data_codebook.R | 6 +- 3 files changed, 63 insertions(+), 122 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 8127a2e79..9d2474de0 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: datawizard Title: Easy Data Wrangling and Statistical Transformations -Version: 0.13.0.9 +Version: 0.13.0.10 Authors@R: c( person("Indrajeet", "Patil", , "patilindrajeet.science@gmail.com", role = "aut", comment = c(ORCID = "0000-0003-1995-6531")), diff --git a/tests/testthat/_snaps/data_codebook.md b/tests/testthat/_snaps/data_codebook.md index 8cf3ce5fa..83ad46f36 100644 --- a/tests/testthat/_snaps/data_codebook.md +++ b/tests/testthat/_snaps/data_codebook.md @@ -143,48 +143,29 @@ Output efc (100 rows and 5 variables, 5 shown) - ID | Name | Label | Type - ---+----------+------------------------------------------+------------ - 1 | c12hour | average number of hours of care per week | numeric - ---+----------+------------------------------------------+------------ - 2 | e16sex | elder's gender | numeric - ---+----------+------------------------------------------+------------ - ---+----------+------------------------------------------+------------ - 3 | e42dep | elder's dependency | categorical - ---+----------+------------------------------------------+------------ - ---+----------+------------------------------------------+------------ - ---+----------+------------------------------------------+------------ - ---+----------+------------------------------------------+------------ - 4 | c172code | carer's level of education | numeric - ---+----------+------------------------------------------+------------ - ---+----------+------------------------------------------+------------ - ---+----------+------------------------------------------+------------ - 5 | neg_c_7 | Negative impact with 7 items | numeric - ---------------------------------------------------------------------- - - ID | Missings | Values | Value Labels | N - ---+------------+----------+---------------------------------+----------- - 1 | 2 (2.0%) | [5, 168] | | 98 - ---+------------+----------+---------------------------------+----------- - 2 | 0 (0.0%) | 1 | male | 46 (46.0%) - | | 2 | female | 54 (54.0%) - ---+------------+----------+---------------------------------+----------- - 3 | 3 (3.0%) | 1 | independent | 2 ( 2.1%) - | | 2 | slightly dependent | 4 ( 4.1%) - | | 3 | moderately dependent | 28 (28.9%) - | | 4 | severely dependent | 63 (64.9%) - ---+------------+----------+---------------------------------+----------- - 4 | 10 (10.0%) | 1 | low level of education | 8 ( 8.9%) - | | 2 | intermediate level of education | 66 (73.3%) - | | 3 | high level of education | 16 (17.8%) - ---+------------+----------+---------------------------------+----------- - 5 | 3 (3.0%) | [7, 28] | | 97 - ------------------------------------------------------------------------- + ID | Name | Label | Type | Missings | Values | Value Labels | N + ---+----------+------------------------------------------+-------------+------------+----------+---------------------------------+----------- + 1 | c12hour | average number of hours of care per week | numeric | 2 (2.0%) | [5, 168] | | 98 + ---+----------+------------------------------------------+-------------+------------+----------+---------------------------------+----------- + 2 | e16sex | elder's gender | numeric | 0 (0.0%) | 1 | male | 46 (46.0%) + | | | | | 2 | female | 54 (54.0%) + ---+----------+------------------------------------------+-------------+------------+----------+---------------------------------+----------- + 3 | e42dep | elder's dependency | categorical | 3 (3.0%) | 1 | independent | 2 ( 2.1%) + | | | | | 2 | slightly dependent | 4 ( 4.1%) + | | | | | 3 | moderately dependent | 28 (28.9%) + | | | | | 4 | severely dependent | 63 (64.9%) + ---+----------+------------------------------------------+-------------+------------+----------+---------------------------------+----------- + 4 | c172code | carer's level of education | numeric | 10 (10.0%) | 1 | low level of education | 8 ( 8.9%) + | | | | | 2 | intermediate level of education | 66 (73.3%) + | | | | | 3 | high level of education | 16 (17.8%) + ---+----------+------------------------------------------+-------------+------------+----------+---------------------------------+----------- + 5 | neg_c_7 | Negative impact with 7 items | numeric | 3 (3.0%) | [7, 28] | | 97 + --------------------------------------------------------------------------------------------------------------------------------------------- --- Code - print(data_codebook(efc)) + print(data_codebook(efc), table_width = "auto") Output efc (100 rows and 5 variables, 5 shown) @@ -233,50 +214,30 @@ Output efc (100 rows and 5 variables, 5 shown) - ID | Name | Label | Type | Missings - ---+----------+------------------------------+-------------+----------- - 1 | c12hour | average number of hours of | numeric | 2 (2.0%) - | | care per week | | - ---+----------+------------------------------+-------------+----------- - 2 | e16sex | elder's gender | numeric | 0 (0.0%) - ---+----------+------------------------------+-------------+----------- - ---+----------+------------------------------+-------------+----------- - 3 | e42dep | elder's dependency | categorical | 3 (3.0%) - ---+----------+------------------------------+-------------+----------- - ---+----------+------------------------------+-------------+----------- - ---+----------+------------------------------+-------------+----------- - ---+----------+------------------------------+-------------+----------- - 4 | c172code | carer's level of education | numeric | 10 (10.0%) - ---+----------+------------------------------+-------------+----------- - ---+----------+------------------------------+-------------+----------- - ---+----------+------------------------------+-------------+----------- - 5 | neg_c_7 | Negative impact with 7 items | numeric | 3 (3.0%) - ----------------------------------------------------------------------- - - ID | Values | Value Labels | N - ---+----------+---------------------------------+----------- - 1 | [5, 168] | | 98 - ---+----------+---------------------------------+----------- - ---+----------+---------------------------------+----------- - 2 | 1 | male | 46 (46.0%) - | 2 | female | 54 (54.0%) - ---+----------+---------------------------------+----------- - 3 | 1 | independent | 2 ( 2.1%) - | 2 | slightly dependent | 4 ( 4.1%) - | 3 | moderately dependent | 28 (28.9%) - | 4 | severely dependent | 63 (64.9%) - ---+----------+---------------------------------+----------- - 4 | 1 | low level of education | 8 ( 8.9%) - | 2 | intermediate level of education | 66 (73.3%) - | 3 | high level of education | 16 (17.8%) - ---+----------+---------------------------------+----------- - 5 | [7, 28] | | 97 - ------------------------------------------------------------ + ID | Name | Label | Type | Missings | Values | Value Labels | N + ---+----------+------------------------------+-------------+------------+----------+---------------------------------+----------- + 1 | c12hour | average number of hours of | numeric | 2 (2.0%) | [5, 168] | | 98 + | | care per week | | | | | + ---+----------+------------------------------+-------------+------------+----------+---------------------------------+----------- + 2 | e16sex | elder's gender | numeric | 0 (0.0%) | 1 | male | 46 (46.0%) + | | | | | 2 | female | 54 (54.0%) + ---+----------+------------------------------+-------------+------------+----------+---------------------------------+----------- + 3 | e42dep | elder's dependency | categorical | 3 (3.0%) | 1 | independent | 2 ( 2.1%) + | | | | | 2 | slightly dependent | 4 ( 4.1%) + | | | | | 3 | moderately dependent | 28 (28.9%) + | | | | | 4 | severely dependent | 63 (64.9%) + ---+----------+------------------------------+-------------+------------+----------+---------------------------------+----------- + 4 | c172code | carer's level of education | numeric | 10 (10.0%) | 1 | low level of education | 8 ( 8.9%) + | | | | | 2 | intermediate level of education | 66 (73.3%) + | | | | | 3 | high level of education | 16 (17.8%) + ---+----------+------------------------------+-------------+------------+----------+---------------------------------+----------- + 5 | neg_c_7 | Negative impact with 7 items | numeric | 3 (3.0%) | [7, 28] | | 97 + --------------------------------------------------------------------------------------------------------------------------------- --- Code - print(out) + print(out, table_width = "auto") Output efc (100 rows and 5 variables, 5 shown) @@ -327,50 +288,30 @@ Output efc (100 rows and 5 variables, 5 shown) - ID | Name | Label | Type | Missings - ---+----------+------------------------------+-------------+----------- - 1 | c12hour | average number of hours of | numeric | 2 (2.0%) - | | care per week | | - ---+----------+------------------------------+-------------+----------- - 2 | e16sex | elder's gender | numeric | 0 (0.0%) - ---+----------+------------------------------+-------------+----------- - ---+----------+------------------------------+-------------+----------- - 3 | e42dep | elder's dependency | categorical | 3 (3.0%) - ---+----------+------------------------------+-------------+----------- - ---+----------+------------------------------+-------------+----------- - ---+----------+------------------------------+-------------+----------- - ---+----------+------------------------------+-------------+----------- - 4 | c172code | carer's level of education | numeric | 10 (10.0%) - ---+----------+------------------------------+-------------+----------- - ---+----------+------------------------------+-------------+----------- - ---+----------+------------------------------+-------------+----------- - 5 | neg_c_7 | Negative impact with 7 items | numeric | 3 (3.0%) - ----------------------------------------------------------------------- - - ID | Values | Value Labels | N - ---+----------+------------------+----------- - 1 | [5, 168] | | 98 - ---+----------+------------------+----------- - ---+----------+------------------+----------- - 2 | 1 | male | 46 (46.0%) - | 2 | female | 54 (54.0%) - ---+----------+------------------+----------- - 3 | 1 | independent | 2 ( 2.1%) - | 2 | slightly... | 4 ( 4.1%) - | 3 | moderately... | 28 (28.9%) - | 4 | severely... | 63 (64.9%) - ---+----------+------------------+----------- - 4 | 1 | low level of... | 8 ( 8.9%) - | 2 | intermediate... | 66 (73.3%) - | 3 | high level of... | 16 (17.8%) - ---+----------+------------------+----------- - 5 | [7, 28] | | 97 - --------------------------------------------- + ID | Name | Label | Type | Missings | Values | Value Labels | N + ---+----------+------------------------------+-------------+------------+----------+------------------+----------- + 1 | c12hour | average number of hours of | numeric | 2 (2.0%) | [5, 168] | | 98 + | | care per week | | | | | + ---+----------+------------------------------+-------------+------------+----------+------------------+----------- + 2 | e16sex | elder's gender | numeric | 0 (0.0%) | 1 | male | 46 (46.0%) + | | | | | 2 | female | 54 (54.0%) + ---+----------+------------------------------+-------------+------------+----------+------------------+----------- + 3 | e42dep | elder's dependency | categorical | 3 (3.0%) | 1 | independent | 2 ( 2.1%) + | | | | | 2 | slightly... | 4 ( 4.1%) + | | | | | 3 | moderately... | 28 (28.9%) + | | | | | 4 | severely... | 63 (64.9%) + ---+----------+------------------------------+-------------+------------+----------+------------------+----------- + 4 | c172code | carer's level of education | numeric | 10 (10.0%) | 1 | low level of... | 8 ( 8.9%) + | | | | | 2 | intermediate... | 66 (73.3%) + | | | | | 3 | high level of... | 16 (17.8%) + ---+----------+------------------------------+-------------+------------+----------+------------------+----------- + 5 | neg_c_7 | Negative impact with 7 items | numeric | 3 (3.0%) | [7, 28] | | 97 + ------------------------------------------------------------------------------------------------------------------ --- Code - print(out) + print(out, table_width = "auto") Output efc (100 rows and 5 variables, 5 shown) diff --git a/tests/testthat/test-data_codebook.R b/tests/testthat/test-data_codebook.R index 1e3fb0804..f8ced0cab 100644 --- a/tests/testthat/test-data_codebook.R +++ b/tests/testthat/test-data_codebook.R @@ -39,21 +39,21 @@ test_that("data_codebook iris, select, ID", { test_that("data_codebook efc", { expect_snapshot(print(data_codebook(efc), table_width = Inf)) - expect_snapshot(print(data_codebook(efc))) + expect_snapshot(print(data_codebook(efc), table_width = "auto")) }) test_that("data_codebook efc, variable_label_width", { out <- data_codebook(efc, variable_label_width = 30) expect_snapshot(print(out, table_width = Inf)) - expect_snapshot(print(out)) + expect_snapshot(print(out, table_width = "auto")) }) test_that("data_codebook efc, value_label_width", { out <- data_codebook(efc, variable_label_width = 30, value_label_width = 15) expect_snapshot(print(out, table_width = Inf)) - expect_snapshot(print(out)) + expect_snapshot(print(out, table_width = "auto")) })