Skip to content

Commit

Permalink
Merge pull request #17 from atorus-research/release_0.4.4
Browse files Browse the repository at this point in the history
Release 0.4.4
  • Loading branch information
elimillera committed Jan 27, 2022
2 parents a152af1 + c298bc6 commit dabbcbf
Show file tree
Hide file tree
Showing 41 changed files with 963 additions and 257 deletions.
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,4 @@ Suggests:
VignetteBuilder: knitr
RoxygenNote: 7.1.2
RdMacros: lifecycle
Config/testthat/edition: 3
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Tplyr 0.4.3.9000 (Development)
# Tplyr 0.4.4

- Added new functionality per issue #10. Adds 'Both' an option for sorting outer layers of nested count.

Expand Down
4 changes: 2 additions & 2 deletions R/count.R
Original file line number Diff line number Diff line change
Expand Up @@ -245,15 +245,15 @@ filter_nested_inner_layer <- function(.group, target, outer_name, inner_name, in

if(text_outer) {
target_inner_values <- target %>%
select(inner_name) %>%
select(any_of(inner_name)) %>%
unlist() %>%
paste0(indentation, .)
} else {
current_outer_value <- unique(.group[, outer_name])[[1]]

target_inner_values <- target %>%
filter(!!sym(outer_name) == current_outer_value) %>%
select(inner_name) %>%
select(any_of(inner_name)) %>%
unlist() %>%
paste0(indentation, .)
}
Expand Down
4 changes: 2 additions & 2 deletions R/nested.R
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ filter_nested_inner_layer <- function(.group, target, outer_name, inner_name, in
if(text_outer) {
lvs <- levels(target[[inner_name]])
target_inner_values <- target %>%
select(inner_name) %>%
select(any_of(inner_name)) %>%
unlist() %>%
c(lvs) %>%
unique() %>%
Expand All @@ -93,7 +93,7 @@ filter_nested_inner_layer <- function(.group, target, outer_name, inner_name, in

target_inner_values <- target %>%
filter(!!sym(outer_name) == current_outer_value) %>%
select(inner_name) %>%
select(any_of(inner_name)) %>%
unlist() %>%
paste0(indentation, .)
}
Expand Down
1 change: 1 addition & 0 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## Submission 0.4.4
* Functionality update for sorting nested count layers
* Updates for changes to rlang

## Test Environments

Expand Down
40 changes: 40 additions & 0 deletions tests/testthat/_snaps/column_headers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# All columns must be character

When binding headers, all columns must be character

# Nested headers are not allowed

Nested spanning headers are not yet supported

# Header strings must have the same number of columns as the data frame

Number of columns provided in header string does not match data

---

Number of columns provided in header string does not match data

---

Number of columns provided in header string does not match data

---

Number of columns provided in header string does not match data

---

Number of columns provided in header string does not match data

---

Number of columns provided in header string does not match data

# Unmatched spanner brackers

Unmatched brackets for spanning headers

# add_column_headers throws an error when you use a token and don't pass header_n

You must pass a header_n if you are using replacement tokens

156 changes: 156 additions & 0 deletions tests/testthat/_snaps/count.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
# Count layer clauses with invalid syntax give informative error

group_count `where` condition `bad == code` is invalid. Filter error:
Error in `h()`:
! Problem with `filter()` input `..1`.
i Input `..1` is `bad == code`.
x object 'bad' not found


# Total rows and missing counts are displayed correctly(0.1.5 Updates)

structure(list(row_label1 = c("6", "8", "Missing", "Total"),
var1_3 = c(" 2 (13.3)", "12 (80.0)", " 1", " 15 [100.0]"
), var1_4 = c(" 4 (33.3)", " 0 ( 0.0)", " 8", " 12 [100.0]"
), var1_5 = c(" 1 (20.0)", " 2 (40.0)", " 2", " 5 [100.0]"
), ord_layer_index = c(1L, 1L, 1L, 1L), ord_layer_1 = c(1,
2, 3, 4)), row.names = c(NA, -4L), class = c("tbl_df", "tbl",
"data.frame"))

---

structure(list(row_label1 = c("6", "8", "Missing", "Not Found",
"Total"), var1_3 = c(" 2 (13.3)", "12 (80.0)", " 1", " 0", " 15 [100.0]"
), var1_4 = c(" 4 (33.3)", " 0 ( 0.0)", " 8", " 0", " 12 [100.0]"
), var1_5 = c(" 1 (20.0)", " 2 (40.0)", " 2", " 0", " 5 [100.0]"
), ord_layer_index = c(1L, 1L, 1L, 1L, 1L), ord_layer_1 = c(1,
2, 3, 4, 5)), row.names = c(NA, -5L), class = c("tbl_df", "tbl",
"data.frame"))

---

structure(list(row_label1 = c("0", "Missing", "Not Found", "Total"
), var1_3 = c("15 (100.0)", " 0", " 0", " 15 [100.0]"), var1_4 = c(" 4 (33.3)",
" 8", " 0", " 12 [100.0]"), var1_5 = c(" 0 ( 0.0)", " 5", " 0",
" 5 [100.0]"), ord_layer_index = c(1L, 1L, 1L, 1L), ord_layer_1 = c(1,
5689, 5690, 9999)), row.names = c(NA, -4L), class = c("tbl_df",
"tbl", "data.frame"))

---

structure(list(row_label1 = c("6", "8", "Missing", "Not Found",
"Total"), var1_3 = c(" 2 (13.3)", "12 (80.0)", " 1", " 0", " 15 [100.0]"
), var1_4 = c(" 4 (33.3)", " 0 ( 0.0)", " 8", " 0", " 12 [100.0]"
), var1_5 = c(" 1 (20.0)", " 2 (40.0)", " 2", " 0", " 5 [100.0]"
), ord_layer_index = c(1L, 1L, 1L, 1L, 1L), ord_layer_1 = c(4,
0, 999, 1000, 9999)), row.names = c(NA, -5L), class = c("tbl_df",
"tbl", "data.frame"))

---

structure(list(row_label1 = c("6", "8", "Missing", "Total"),
var1_3 = c(" 2 (13.3)", "12 (80.0)", " 1", " 15 [100.0]"
), var1_4 = c(" 4 (33.3)", " 0 ( 0.0)", " 8", " 12 [100.0]"
), var1_5 = c(" 1 (20.0)", " 2 (40.0)", " 2", " 5 [100.0]"
), ord_layer_index = c(1L, 1L, 1L, 1L), ord_layer_1 = c(1,
2, 3, 7862)), row.names = c(NA, -4L), class = c("tbl_df",
"tbl", "data.frame"))

---

structure(list(row_label1 = c("0", "Missing", "Total"), var1_3 = c("15 (100.0)",
" 0", " 15 [100.0]"), var1_4 = c(" 4 (33.3)", " 8", " 12 [100.0]"
), var1_5 = c(" 0 ( 0.0)", " 5", " 5 [100.0]"), ord_layer_index = c(1L,
1L, 1L), ord_layer_1 = c(1, 3, -Inf)), row.names = c(NA, -3L), class = c("tbl_df",
"tbl", "data.frame"))

---

structure(list(row_label1 = c("6", "8", "Missing", "Total"),
var1_3 = c(" 2 (13.3)", "12 (80.0)", " 1", " 15 [100.0]"
), var1_4 = c(" 4 (33.3)", " 0 ( 0.0)", " 8", " 12 [100.0]"
), var1_5 = c(" 1 (20.0)", " 2 (40.0)", " 2", " 5 [100.0]"
), ord_layer_index = c(1L, 1L, 1L, 1L), ord_layer_1 = c(4,
0, 8, -6795)), row.names = c(NA, -4L), class = c("tbl_df",
"tbl", "data.frame"))

---

structure(list(row_label1 = c("6", "8", "NA", "Total"), var1_3 = c(" 2 (13.3)",
"12 (80.0)", " 1 ( 6.7)", "15 (100.0)"), var1_4 = c(" 4 (33.3)",
" 0 ( 0.0)", " 8 (66.7)", "12 (100.0)"), var1_5 = c(" 1 (20.0)",
" 2 (40.0)", " 2 (40.0)", " 5 (100.0)"), ord_layer_index = c(1L,
1L, 1L, 1L), ord_layer_1 = c(1, 2, 3, 3)), row.names = c(NA,
-4L), class = c("tbl_df", "tbl", "data.frame"))

---

structure(list(row_label1 = c("2", "3", "4", "6", "8", "Missing_"
), var1_3 = c(" 0 ( 0.0)", " 0 ( 0.0)", " 0 ( 0.0)", " 2 (13.3)",
"12 (80.0)", " 1"), var1_4 = c(" 0 ( 0.0)", " 0 ( 0.0)", " 0 ( 0.0)",
" 4 (33.3)", " 0 ( 0.0)", " 8"), var1_5 = c(" 0 ( 0.0)", " 0 ( 0.0)",
" 0 ( 0.0)", " 1 (20.0)", " 2 (40.0)", " 2"), ord_layer_index = c(1L,
1L, 1L, 1L, 1L, 1L), ord_layer_1 = c(1, 2, 3, 4, 5, 6)), row.names = c(NA,
-6L), class = c("tbl_df", "tbl", "data.frame"))

# set_denom_where works as expected

structure(list(row_label1 = c("4", "8"), var1_3 = c(" 1 ( 6.7)",
"12 (80.0)"), var1_4 = c(" 8 (66.7)", " 0 ( 0.0)"), var1_5 = c(" 2 (40.0)",
" 2 (40.0)"), ord_layer_index = c(1L, 1L), ord_layer_1 = c(1,
3)), row.names = c(NA, -2L), class = c("tbl_df", "tbl", "data.frame"
))

---

structure(list(row_label1 = c("4", "8"), var1_3 = c(" 1 ( 7.1)",
"12 (85.7)"), var1_4 = c(" 8 (200.0)", " 0 ( 0.0)"), var1_5 = c(" 2 (66.7)",
" 2 (66.7)"), ord_layer_index = c(1L, 1L), ord_layer_1 = c(1,
3)), row.names = c(NA, -2L), class = c("tbl_df", "tbl", "data.frame"
))

---

A `denom_where` has been set with a pop_data. The `denom_where` has been ignored.You should use `set_pop_where` instead of `set_denom_where`.


---

structure(list(row_label1 = c("4", "8"), var1_3 = c(" 1 ( 7.7)",
"12 (92.3)"), var1_4 = c(" 8 (100.0)", " 0 ( 0.0)"), var1_5 = c(" 2 (50.0)",
" 2 (50.0)"), ord_layer_index = c(1L, 1L), ord_layer_1 = c(1,
3)), row.names = c(NA, -2L), class = c("tbl_df", "tbl", "data.frame"
))

# nested count layers can accecpt text values in the first variable

Inner layers must be data driven variables

# Variable names will be coersed into symbols

The first target variable has been coerced into a symbol. You should pass variable names unquoted.

---

The second target variable has been coerced into a symbol.You should pass variable names unquoted.

# keep_levels works as expeceted

group_count `where` condition `TRUE` is invalid. Filter error:
Error: level passed to `kept_levels` not found: 10 20


---

group_count `where` condition `TRUE` is invalid. Filter error:
Error: level passed to `kept_levels` not found: nothere


# nested count layers handle `set_denoms_by` as expected

You can not pass the second variable in `vars` as a denominator.

# nested count layers will error out if second variable is bigger than the first

The number of values of your second variable must be greater than the number of levels in your first variable

9 changes: 9 additions & 0 deletions tests/testthat/_snaps/desc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Desc layer clauses with invalid syntax give informative error

group_desc `where` condition `bad == code` is invalid. Filter error:
Error in `h()`:
! Problem with `filter()` input `..1`.
i Input `..1` is `bad == code`.
x object 'bad' not found


12 changes: 12 additions & 0 deletions tests/testthat/_snaps/format.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Format string must be character

Argument `format_string` must be character. Instead a class of "numeric" was passed.

# Error is thrown when format doesn't match variables

In `f_str` 2 formats were entered in the format string xx.x xx.xbut 1 variables were assigned.

---

In `f_str` 1 formats were entered in the format string xx.xbut 2 variables were assigned.

8 changes: 8 additions & 0 deletions tests/testthat/_snaps/functional.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# all test tables can be built without errors or warnings

Problem with `mutate()` column `col_i`.
i `col_i = fct_expand(...)`.
x object 'col_i' not found
Caused by error:
! object 'col_i' not found

48 changes: 48 additions & 0 deletions tests/testthat/_snaps/get_numeric.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Error handling - numeric

If `where` is provided, a single `layer` value must be specified

---

If `where` is provided, a single `layer` value must be specified

---

Layer(s) blah do(es) not exist

---

Layer(s) blah do(es) not exist

---

Provided layer index is out of range

---

Provided layer index is out of range

# Error handling - statistic

If `where` is provided, `layer_name` and `statistic` must be specified

---

If `where` is provided, `layer_name` and `statistic` must be specified

---

Layer(s) blah do(es) not exist

---

Layer(s) am, blah do(es) not exist

---

Provided layer index is out of range

---

Provided layer index is out of range

Loading

0 comments on commit dabbcbf

Please sign in to comment.