Skip to content

Commit 3969e31

Browse files
committed
allow to adjust filtering on clusters, or not
1 parent 5988dab commit 3969e31

File tree

7 files changed

+87
-75
lines changed

7 files changed

+87
-75
lines changed

DESCRIPTION

Lines changed: 70 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,70 @@
1-
Package: tabshiftr
2-
Title: Reshape Disorganised Messy Data
3-
Version: 0.5.1
4-
Authors@R:
5-
c(person(given = "Steffen",
6-
family = "Ehrmann",
7-
role = c("aut", "cre"),
8-
email = "[email protected]",
9-
comment = c(ORCID = "0000-0002-2958-0796")),
10-
person(given = "Tsvetelina",
11-
family = "Tomova",
12-
role = "ctb",
13-
email = "[email protected]"),
14-
person(given = "Carsten",
15-
family = "Meyer",
16-
role = "aut",
17-
email = "[email protected]",
18-
comment = c(ORCID = "0000-0003-3927-5856")),
19-
person(given = "Abdualmaged",
20-
family = "Alhemiary",
21-
role = "ctb"),
22-
person(given = "Amelie",
23-
family = "Haas",
24-
role = "ctb"),
25-
person(given = "Annika",
26-
family = "Ertel",
27-
role = "ctb"),
28-
person(given = "Arne",
29-
family = "Rümmler",
30-
role = "ctb",
31-
email = "[email protected]",
32-
comment = c(ORCID = "0000-0001-8637-9071")),
33-
person(given = "Caroline",
34-
family = "Busse",
35-
role = "ctb"))
36-
Description: Helps the user to build and register schema descriptions of
37-
disorganised (messy) tables. Disorganised tables are tables that are
38-
not in a topologically coherent form, where packages such as 'tidyr' could
39-
be used for reshaping. The schema description documents the arrangement of
40-
input tables and is used to reshape them into a standardised (tidy) output
41-
format.
42-
URL: https://luckinet.github.io/tabshiftr/, https://github.com/luckinet/tabshiftr
43-
BugReports: https://github.com/luckinet/tabshiftr/issues
44-
Depends:
45-
R (>= 2.10)
46-
Language: en-gb
47-
License: GPL-3
48-
Encoding: UTF-8
49-
LazyData: true
50-
Imports:
51-
checkmate,
52-
rlang,
53-
tibble,
54-
dplyr,
55-
tidyr,
56-
magrittr,
57-
tidyselect,
58-
testthat,
59-
crayon,
60-
methods,
61-
purrr,
62-
stringr,
63-
lubridate
64-
RoxygenNote: 7.3.2
65-
Suggests:
66-
knitr,
67-
rmarkdown,
68-
bookdown,
69-
readr
70-
VignetteBuilder: knitr
1+
Package: tabshiftr
2+
Title: Reshape Disorganised Messy Data
3+
Version: 0.5.1
4+
Authors@R:
5+
c(person(given = "Steffen",
6+
family = "Ehrmann",
7+
role = c("aut", "cre"),
8+
email = "[email protected]",
9+
comment = c(ORCID = "0000-0002-2958-0796")),
10+
person(given = "Tsvetelina",
11+
family = "Tomova",
12+
role = "ctb",
13+
email = "[email protected]"),
14+
person(given = "Carsten",
15+
family = "Meyer",
16+
role = "aut",
17+
email = "[email protected]",
18+
comment = c(ORCID = "0000-0003-3927-5856")),
19+
person(given = "Abdualmaged",
20+
family = "Alhemiary",
21+
role = "ctb"),
22+
person(given = "Amelie",
23+
family = "Haas",
24+
role = "ctb"),
25+
person(given = "Annika",
26+
family = "Ertel",
27+
role = "ctb"),
28+
person(given = "Arne",
29+
family = "Rümmler",
30+
role = "ctb",
31+
email = "[email protected]",
32+
comment = c(ORCID = "0000-0001-8637-9071")),
33+
person(given = "Caroline",
34+
family = "Busse",
35+
role = "ctb"))
36+
Description: Helps the user to build and register schema descriptions of
37+
disorganised (messy) tables. Disorganised tables are tables that are
38+
not in a topologically coherent form, where packages such as 'tidyr' could
39+
be used for reshaping. The schema description documents the arrangement of
40+
input tables and is used to reshape them into a standardised (tidy) output
41+
format.
42+
URL: https://luckinet.github.io/tabshiftr/, https://github.com/luckinet/tabshiftr
43+
BugReports: https://github.com/luckinet/tabshiftr/issues
44+
Depends:
45+
R (>= 3.5)
46+
Language: en-gb
47+
License: GPL-3
48+
Encoding: UTF-8
49+
LazyData: true
50+
Imports:
51+
checkmate,
52+
rlang,
53+
tibble,
54+
dplyr,
55+
tidyr,
56+
magrittr,
57+
tidyselect,
58+
testthat,
59+
crayon,
60+
methods,
61+
purrr,
62+
stringr,
63+
lubridate
64+
RoxygenNote: 7.3.2
65+
Suggests:
66+
knitr,
67+
rmarkdown,
68+
bookdown,
69+
readr
70+
VignetteBuilder: knitr

R/schema.R

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,8 @@ setValidity(Class = "schema", function(object){
228228
if(length(object@filter) == 0){
229229
errors <- c(errors, "the slot 'filter' does not contain any entries.")
230230
}
231-
if(!all(names(object@filter) %in% c("row", "col"))){
232-
errors <- c(errors, "'names(schema$filter)' must be a permutation of set {row,col}")
231+
if(!all(names(object@filter) %in% c("row", "col", "clusters"))){
232+
errors <- c(errors, "'names(schema$filter)' must be a permutation of set {row,col, clusters}")
233233
}
234234
if(!is.null(object@filter$row)){
235235
if(!is.numeric(object@filter$row)){
@@ -241,6 +241,11 @@ setValidity(Class = "schema", function(object){
241241
errors <- c(errors, "'schema$filter$col' must have a numeric value.")
242242
}
243243
}
244+
if(!is.null(object@filter$clusters)){
245+
if(!is.logical(object@filter$clusters)){
246+
errors <- c(errors, "'schema$filter$clusters' must have a logical value.")
247+
}
248+
}
244249
}
245250

246251
if(!.hasSlot(object = object, name = "variables")){

R/setFilter.R

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#' kept.
1010
#' @param invert [\code{logical(1)}]\cr whether or not to invert the specified
1111
#' columns or rows.
12+
#' @param clusters [\code{logical(1)}]\cr whether or not to filter cluster rows.
1213
#' @param operator [\code{function(1)}]\cr \code{\link[base]{Logic}} operators
1314
#' by which the current filter should be combined with the directly preceeding
1415
#' filter; hence this argument is not used in case no other filter was defined
@@ -33,7 +34,7 @@
3334
#' @export
3435

3536
setFilter <- function(schema = NULL, rows = NULL, columns = NULL, invert = FALSE,
36-
operator = NULL){
37+
clusters = TRUE, operator = NULL){
3738

3839
# assertions ----
3940
assertClass(x = schema, classes = "schema", null.ok = TRUE)
@@ -46,6 +47,7 @@ setFilter <- function(schema = NULL, rows = NULL, columns = NULL, invert = FALSE
4647
if(rowList) assertSubset(x = names(rows), choices = c("find"))
4748
if(colList) assertSubset(x = names(columns), choices = c("find"))
4849
assertLogical(x = invert, any.missing = FALSE)
50+
assertLogical(x = clusters, any.missing = FALSE)
4951

5052
# update schema ----
5153
if(is.null(schema)){
@@ -76,6 +78,8 @@ setFilter <- function(schema = NULL, rows = NULL, columns = NULL, invert = FALSE
7678
schema@filter$col <- c(schema@filter$col, columns)
7779
}
7880

81+
schema@filter$clusters <- clusters
82+
7983
# test for problems ----
8084
# reportProblems(schema = schema)
8185

R/validateSchema.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ validateSchema <- function(schema = NULL, input = NULL){
7171
clusters$row <- .eval_find(input = input, row = clusters$row, clusters = clusters)
7272

7373
# ignore filter rows
74-
if(!is.null(filter$row)){
74+
if(filter$clusters & !is.null(filter$row)){
7575
clusters$row <- clusters$row[clusters$row %in% filter$row]
7676
}
7777
clusters$row <- .eval_sum(input = input, groups = groups, data = clusters$row)

data/schema_default.rda

11 Bytes
Binary file not shown.

man/setFilter.Rd

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tabshiftr.Rproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Version: 1.0
2-
ProjectId: 24d10686-dec0-4212-b538-0958fbc3a23b
2+
ProjectId: 934225e6-a5a1-4111-86d0-eb38315d6cde
33

44
RestoreWorkspace: Default
55
SaveWorkspace: Default

0 commit comments

Comments
 (0)