-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from r-world-devs/v0.2.0
v0.2.0 release
- Loading branch information
Showing
7 changed files
with
105 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
Package: cohortBuilder | ||
Type: Package | ||
Title: Data Source Agnostic Filtering Tools | ||
Version: 0.1.2.9000 | ||
Version: 0.2.0 | ||
Authors@R: | ||
c(person('Krystian', 'Igras', | ||
email = '[email protected]', | ||
|
@@ -16,14 +16,14 @@ License: MIT + file LICENSE | |
Encoding: UTF-8 | ||
LazyData: true | ||
Imports: | ||
yaml, | ||
R6, | ||
jsonlite, | ||
purrr, | ||
tibble, | ||
dplyr (>= 1.0.0), | ||
tidyr, | ||
magrittr, | ||
glue, | ||
R6, | ||
ggplot2, | ||
rlang (>= 1.0), | ||
formatR | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
|
||
# cohortBuilder <img src="man/figures/logo.png" align="right" width="120" /> | ||
|
||
[![version](https://img.shields.io/static/v1.svg?label=github.com&message=v.0.1.1&color=ff69b4)](https://r-world-devs.github.io/cohortBuilder/) | ||
[![version](https://img.shields.io/static/v1.svg?label=github.com&message=v.0.2.0&color=ff69b4)](https://r-world-devs.github.io/cohortBuilder/) | ||
[![lifecycle](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental) | ||
|
||
## Overview | ||
|
@@ -17,24 +17,24 @@ With only two steps: | |
|
||
You can operate on data using common methods, such as: | ||
|
||
- `filter` - to define and `run` to apply filtering rules, | ||
- `step` - to perform multi-stage filtering, | ||
- `get_data`, `stat`, `attrition`, `plot_data` - to extract, sum up or | ||
visualize your cohort data. | ||
- `filter` - to define and `run` to apply filtering rules, | ||
- `step` - to perform multi-stage filtering, | ||
- `get_data`, `stat`, `attrition`, `plot_data` - to extract, sum up or | ||
visualize your cohort data. | ||
|
||
With `cohortBuilder` you can share the cohort easier with useful | ||
methods: | ||
|
||
- `code` - to get reproducible cohort creation code, | ||
- `get_state` - to get cohort state (e.g. in JSON) that can be then | ||
easily restored with `restore`. | ||
- `code` - to get reproducible cohort creation code, | ||
- `get_state` - to get cohort state (e.g. in JSON) that can be then | ||
easily restored with `restore`. | ||
|
||
Or modify the cohort configuration with: | ||
|
||
- `add_filter`, `rm_filter`, `update_filter` - to manage filters | ||
definition | ||
- `add_step`, `rm_step` - to manage filtering steps, | ||
- `update_source` - to manage the cohort source. | ||
- `add_filter`, `rm_filter`, `update_filter` - to manage filters | ||
definition | ||
- `add_step`, `rm_step` - to manage filtering steps, | ||
- `update_source` - to manage the cohort source. | ||
|
||
## Data sources and extensions | ||
|
||
|
@@ -354,24 +354,58 @@ code(coh) | |
#> } | ||
#> return(data_object) | ||
#> } | ||
#> .run_binding <- function(source, binding_key, data_object_pre, data_object_post, | ||
#> ...) { | ||
#> binding_dataset <- binding_key$update$dataset | ||
#> dependent_datasets <- names(binding_key$data_keys) | ||
#> active_datasets <- data_object_post %>% | ||
#> purrr::keep(~attr(., "filtered")) %>% | ||
#> names() | ||
#> if (!any(dependent_datasets %in% active_datasets)) { | ||
#> return(data_object_post) | ||
#> } | ||
#> key_values <- NULL | ||
#> common_key_names <- paste0("key_", seq_along(binding_key$data_keys[[1]]$key)) | ||
#> for (dependent_dataset in dependent_datasets) { | ||
#> key_names <- binding_key$data_keys[[dependent_dataset]]$key | ||
#> tmp_key_values <- dplyr::distinct(data_object_post[[dependent_dataset]][, | ||
#> key_names, drop = FALSE]) %>% | ||
#> stats::setNames(common_key_names) | ||
#> if (is.null(key_values)) { | ||
#> key_values <- tmp_key_values | ||
#> } else { | ||
#> key_values <- dplyr::inner_join(key_values, tmp_key_values, by = common_key_names) | ||
#> } | ||
#> } | ||
#> data_object_post[[binding_dataset]] <- dplyr::inner_join(switch(as.character(binding_key$post), | ||
#> `FALSE` = data_object_pre[[binding_dataset]], `TRUE` = data_object_post[[binding_dataset]]), | ||
#> key_values, by = stats::setNames(common_key_names, binding_key$update$key)) | ||
#> if (binding_key$activate) { | ||
#> attr(data_object_post[[binding_dataset]], "filtered") <- TRUE | ||
#> } | ||
#> return(data_object_post) | ||
#> } | ||
#> source <- list(dtconn = as.tblist(librarian)) | ||
#> data_object <- source$dtconn | ||
#> # step 1 | ||
#> step_id <- "1" | ||
#> data_object <- .pre_filtering(source, data_object, step_id) | ||
#> pre_data_object <- data_object | ||
#> data_object <- .pre_filtering(source, data_object, "1") | ||
#> data_object[["books"]] <- data_object[["books"]] %>% | ||
#> dplyr::filter(author %in% c("Dan Brown", NA)) | ||
#> attr(data_object[["books"]], "filtered") <- TRUE | ||
#> data_object[["borrowers"]] <- data_object[["borrowers"]] %>% | ||
#> dplyr::filter((registered <= Inf & registered >= 14610) | is.na(registered)) | ||
#> attr(data_object[["borrowers"]], "filtered") <- TRUE | ||
#> # step 2 | ||
#> data_object <- .post_filtering(source, data_object, "1") | ||
#> for (binding_key in binding_keys) { | ||
#> data_object <- .run_binding(source, binding_key, pre_data_object, data_object) | ||
#> } | ||
#> step_id <- "2" | ||
#> data_object <- .pre_filtering(source, data_object, step_id) | ||
#> data_object <- .pre_filtering(source, data_object, "2") | ||
#> data_object[["books"]] <- data_object[["books"]] %>% | ||
#> dplyr::filter((copies <= 10 & copies >= 5) | is.na(copies)) | ||
#> attr(data_object[["books"]], "filtered") <- TRUE | ||
#> data_object | ||
#> data_object <- .post_filtering(source, data_object, "2") | ||
``` | ||
|
||
``` r | ||
|
@@ -382,21 +416,21 @@ attrition(coh, dataset = "books") | |
|
||
``` r | ||
get_state(coh, json = TRUE) | ||
#> [{"step":"1","filters":[{"range":[5,6],"type":"discrete","id":"author","name":"author","variable":"author","value":"Dan Brown","dataset":"books","keep_na":true,"description":null,"active":true},{"type":"date_range","id":"registered","name":"registered","variable":"registered","range":["2010-01-01","NA"],"dataset":"borrowers","keep_na":true,"description":null,"active":true}]},{"step":"2","filters":[{"type":"range","id":"copies","name":"copies","variable":"copies","range":[5,10],"dataset":"books","keep_na":true,"description":null,"active":true}]}] | ||
#> [{"step":"1","filters":[{"range":[5,6],"type":"discrete","id":"author","name":"author","variable":"author","value":"Dan Brown","dataset":"books","keep_na":true,"description":null,"active":true},{"type":"date_range","id":"registered","name":"registered","variable":"registered","range":["2010-01-01","Inf"],"dataset":"borrowers","keep_na":true,"description":null,"active":true}]},{"step":"2","filters":[{"type":"range","id":"copies","name":"copies","variable":"copies","range":[5,10],"dataset":"books","keep_na":true,"description":null,"active":true}]}] | ||
``` | ||
|
||
## Acknowledgement | ||
|
||
Special thanks to: | ||
|
||
- [Kamil Wais](mailto:[email protected]) for highlighting the need | ||
for the package and its relevance to real-world applications. | ||
- [Adam Foryś](mailto:[email protected]) for technical support, | ||
numerous suggestions for the current and future implementation of | ||
the package. | ||
- [Paweł Kawski](mailto:[email protected]) for indication of | ||
initial assumptions about the package based on real-world medical | ||
data. | ||
- [Kamil Wais](mailto:[email protected]) for highlighting the need | ||
for the package and its relevance to real-world applications. | ||
- [Adam Foryś](mailto:[email protected]) for technical support, | ||
numerous suggestions for the current and future implementation of the | ||
package. | ||
- [Paweł Kawski](mailto:[email protected]) for indication of | ||
initial assumptions about the package based on real-world medical | ||
data. | ||
|
||
## Getting help | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
## Test environments | ||
* local check | ||
Ubuntu 18.04.6 LTS, R 4.1.2 (2021-11-01) | ||
Ubuntu 20.04.5 LTS, R 4.1.2 (2021-11-01) | ||
* win-builder | ||
R version 4.1.3 (2022-03-10) | ||
R version 4.2.1 (2022-06-23 ucrt) | ||
R Under development (unstable) (2022-07-26 r82626 ucrt) | ||
R version 4.2.2 (2022-10-31 ucrt) | ||
R Under development (unstable) (2023-02-27 r83911 ucrt) | ||
|
||
## `R CMD check cohortBuilder_0.1.1.tar.gz --as-cran` results | ||
## `R CMD check cohortBuilder_0.2.0.tar.gz --as-cran` results | ||
|
||
``` | ||
* using log directory ‘/home/krystian/Projects/Packages/cohortBuilder.Rcheck’ | ||
* using R version 4.1.2 (2021-11-01) | ||
* using log directory ‘/home/krystian/projects/cohortBuilder.Rcheck’ | ||
* using R version 4.2.1 (2022-06-23) | ||
* using platform: x86_64-pc-linux-gnu (64-bit) | ||
... | ||
Status: OK | ||
|
@@ -38,7 +38,7 @@ Status: OK | |
|
||
``` | ||
* using log directory 'd:/RCompile/CRANguest/R-release/cohortBuilder.Rcheck' | ||
* using R version 4.2.1 (2022-06-23 ucrt) | ||
* using R version 4.2.2 (2022-10-31 ucrt) | ||
* using platform: x86_64-w64-mingw32 (64-bit) | ||
... | ||
* checking CRAN incoming feasibility ... Note_to_CRAN_maintainers | ||
|
@@ -49,10 +49,10 @@ Status: OK | |
|
||
``` | ||
* using log directory 'd:/RCompile/CRANguest/R-devel/cohortBuilder.Rcheck' | ||
* using R Under development (unstable) (2022-07-26 r82626 ucrt) | ||
* using R Under development (unstable) (2023-02-27 r83911 ucrt) | ||
* using platform: x86_64-w64-mingw32 (64-bit) | ||
... | ||
* checking CRAN incoming feasibility ... Note_to_CRAN_maintainers | ||
* checking CRAN incoming feasibility ... [10s] Note_to_CRAN_maintainers | ||
Maintainer: 'Krystian Igras <[email protected]>' | ||
... | ||
Status: OK | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters