Skip to content

Commit defacb2

Browse files
authored
Merge pull request Infectious-Diseases-Data-Observatory#30 from Infectious-Diseases-Data-Observatory/values_fn_msg
Move value function message into if statements for more accurate value
2 parents 9191ac7 + 61957ef commit defacb2

29 files changed

Lines changed: 255 additions & 69 deletions

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: iddoverse
22
Title: Converting IDDO-SDTM Data To Analysis Datasets
3-
Version: 0.9.0
3+
Version: 0.9.1
44
Authors@R:
55
person("Rhys", "Peploe", , "rhyspeploe1998@gmail.com", role = c("aut", "cre"),
66
comment = c(ORCID = "0009-0001-1669-3716"))

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ importFrom(dplyr,group_by)
2828
importFrom(dplyr,last)
2929
importFrom(dplyr,left_join)
3030
importFrom(dplyr,mutate)
31+
importFrom(dplyr,n)
3132
importFrom(dplyr,relocate)
3233
importFrom(dplyr,rename)
3334
importFrom(dplyr,right_join)

NEWS.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# iddoverse 0.9.1
2+
* prepare_domain: message about the number of rows using value_fn now more accurately reflects the number of rows, as it is now groups by LOC and METHOD if appropiate
3+
* Additional tests to cover change to prepare_domain
4+
* print_messages added to table functions, with equivalent documentation changes
5+
* Logo consistency changes with worlddatr
6+
17
# iddoverse 0.9.0
28
* create_participant_table: baseline timing EPOCH == BASELINE then VISITDY == 1, change from any of VISITDY == 1, DY == 1 and EPOCH == BASELINE
39
* prepare_domain: data first, domain second in parameter order to align with tidy principles, changes to downstream functions, examples, documentation, tests and vignette

R/create_clinical_hist_table.R

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
#' first(), i.e. if there is two rows from the same day and time, the first
2121
#' record will be taken, the second will be dropped. Choice of
2222
#' timing_variables will impact the number of rows affected.
23+
#' @param print_messages Boolean. Should messages from the function be generated
24+
#' and shown in the user's console. Default is TRUE.
2325
#'
2426
#' @returns An analysis dataset, one row per person, per timepoint.
2527
#'
@@ -36,15 +38,17 @@ create_clinical_hist_table <- function(sa_domain,
3638
timing_variables = c(
3739
"SAHR", "SADY", "SASTDY", "SACDSTDY",
3840
"VISITDY", "EPOCH"),
39-
values_funct = first){
41+
values_funct = first,
42+
print_messages = TRUE){
4043
assert_data_frame(sa_domain, required_vars = exprs(SACAT))
4144

4245
data_sa <- sa_domain %>%
4346
filter(SACAT == "MEDICAL HISTORY")
4447

4548
data <- prepare_domain(data_sa, "SA",
4649
variables_include = c("fever", "anemia", "malaria", "hiv"),
47-
timing_variables = timing_variables, values_fn = values_funct) %>%
50+
timing_variables = timing_variables, values_fn = values_funct,
51+
print_messages = print_messages) %>%
4852
remove_empty("cols")
4953

5054
return(data)

R/create_clinical_table.R

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
#' first(), i.e. if there is two rows from the same day and time, the first
1616
#' record will be taken, the second will be dropped. Choice of
1717
#' timing_variables will impact the number of rows affected.
18+
#' @param print_messages Boolean. Should messages from the function be generated
19+
#' and shown in the user's console. Default is TRUE.
1820
#'
1921
#' @returns An analysis dataset, one row per person, per timepoint.
2022
#'
@@ -28,26 +30,30 @@
2830
#'
2931
create_clinical_table <- function(dm_domain, mb_domain = NULL, mp_domain = NULL,
3032
sa_domain = NULL, vs_domain = NULL,
31-
values_funct = first){
33+
values_funct = first,
34+
print_messages = TRUE){
3235
data <- prepare_domain(dm_domain, "dm", variables_include = "")
3336

3437
if(!is.null(mb_domain)){
3538
data <- data %>%
3639
full_join(prepare_domain(mb_domain, "mb", variables_include = c("MTB", "HIV"),
37-
values_fn = values_funct))
40+
values_fn = values_funct,
41+
print_messages = print_messages))
3842
}
3943

4044
if(!is.null(mp_domain)){
4145
data <- data %>%
4246
full_join(prepare_domain(mp_domain, "mp", include_LOC = TRUE,
43-
values_fn = values_funct))
47+
values_fn = values_funct,
48+
print_messages = print_messages))
4449
}
4550

4651

4752
if(!is.null(vs_domain)){
4853
data <- data %>%
4954
full_join(prepare_domain(vs_domain, "vs",
50-
values_fn = values_funct))
55+
values_fn = values_funct,
56+
print_messages = print_messages))
5157
}
5258

5359
if(!is.null(sa_domain)){
@@ -57,7 +63,8 @@ create_clinical_table <- function(dm_domain, mb_domain = NULL, mp_domain = NULL,
5763
"vomiting", "nausea", "fever", "diarrhea",
5864
"abdominal pain", "jaundice", "bleeding",
5965
"anemia", "anorexia", "blood transfusion"),
60-
values_fn = values_funct))
66+
values_fn = values_funct,
67+
print_messages = print_messages))
6168
}
6269

6370
data <- data %>%

R/create_labs_table.R

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
#' Default is first(), i.e. if there is two rows from the same day and time,
2424
#' the first record will be taken, the second will be dropped. Choice of
2525
#' timing_variables will impact the number of rows affected.
26+
#' @param print_messages Boolean. Should messages from the function be generated
27+
#' and shown in the user's console. Default is TRUE.
2628
#'
2729
#' @returns An analysis dataset, one row per person, per timepoint.
2830
#'
@@ -44,12 +46,14 @@ create_labs_table <- function(lb_domain,
4446
timing_variables = c(
4547
"LBHR", "LBDY", "LBSTDY", "LBCDSTDY", "VISITDY",
4648
"EPOCH"),
47-
values_funct = first){
49+
values_funct = first,
50+
print_messages = TRUE){
4851

4952
prepare_domain(lb_domain, "LB",
5053
include_METHOD = include_method,
5154
variables_include = variables,
5255
timing_variables = timing_variables,
53-
values_fn = values_funct)
56+
values_fn = values_funct,
57+
print_messages = print_messages)
5458
}
5559

R/create_malaria_parasitemia_table.R

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
#' Default is first(), i.e. if there is two rows from the same day and time,
2626
#' the first record will be taken, the second will be dropped. Choice of
2727
#' timing_variables will impact the number of rows affected.
28+
#' @param print_messages Boolean. Should messages from the function be generated
29+
#' and shown in the user's console. Default is TRUE.
2830
#'
2931
#' @returns An analysis dataset, one row per person, per timepoint.
3032
#'
@@ -48,12 +50,14 @@ create_malaria_parasitemia_table <- function(mb_domain,
4850
timing_variables = c(
4951
"MBHR", "MBDY", "MBSTDY", "MBCDSTDY",
5052
"VISITDY", "EPOCH"),
51-
values_funct = first){
53+
values_funct = first,
54+
print_messages = TRUE){
5255

5356
prepare_domain(mb_domain, "MB",
5457
include_METHOD = include_method,
5558
include_LOC = include_location,
5659
variables_include = variables,
5760
timing_variables = timing_variables,
58-
values_fn = values_funct)
61+
values_fn = values_funct,
62+
print_messages = print_messages)
5963
}

R/create_malaria_pcr_table.R

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#' first(), i.e. if there is two rows from the same day and time, the first
1414
#' record will be taken, the second will be dropped. Choice of
1515
#' timing_variables will impact the number of rows affected.
16+
#' @param print_messages Boolean. Should messages from the function be generated
17+
#' and shown in the user's console. Default is TRUE.
1618
#'
1719
#' @returns An analysis dataset, one row per person, per timepoint.
1820
#'
@@ -22,20 +24,24 @@
2224
#' create_malaria_pcr_table(PF_RPTESTB, RS_RPTESTB)
2325
#'
2426
create_malaria_pcr_table <- function(pf_domain, rs_domain, ds_domain = NULL,
25-
values_funct = first){
27+
values_funct = first,
28+
print_messages = TRUE){
2629

2730

2831
data_pf <- prepare_domain(pf_domain, "PF", variables_include = "INTP",
29-
values_fn = values_funct)
32+
values_fn = values_funct,
33+
print_messages = print_messages)
3034

3135

3236
data_rs <- prepare_domain(rs_domain, "RS", variables_include = "WHOMAL01",
33-
values_fn = values_funct)
37+
values_fn = values_funct,
38+
print_messages = print_messages)
3439

3540
data <- full_join(data_pf, data_rs)
3641

3742
if(!is.null(ds_domain)){
38-
data_ds <- prepare_domain(ds_domain, "DS", values_fn = values_funct)
43+
data_ds <- prepare_domain(ds_domain, "DS", values_fn = values_funct,
44+
print_messages = print_messages)
3945

4046
data <- full_join(data, data_ds)
4147
}

R/create_participant_table.R

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
#' @param rp_domain A reproductive system findings/RP domain data frame.
1212
#' @param sc_domain A subject characteristics/SC domain data frame.
1313
#' @param vs_domain A vital signs/VS domain data frame.
14+
#' @param print_messages Boolean. Should messages from the function be generated
15+
#' and shown in the user's console. Default is TRUE.
1416
#'
1517
#' @returns An analysis dataset, one row per participant.
1618
#'
@@ -27,7 +29,8 @@ create_participant_table <- function(dm_domain,
2729
mb_domain = NULL,
2830
rp_domain = NULL,
2931
sc_domain = NULL,
30-
vs_domain = NULL){
32+
vs_domain = NULL,
33+
print_messages = TRUE){
3134
data <- prepare_domain(dm_domain, "dm",
3235
variables_include = c("STUDYID", "USUBJID", "AGEU",
3336
"AGE", "SEX","RFSTDTC",
@@ -41,7 +44,8 @@ create_participant_table <- function(dm_domain,
4144
left_join(
4245
prepare_domain(sc_domain, "sc",
4346
variables_include = c("EDULEVEL", "MARISTAT"),
44-
timing_variables = c("VISITDY", "EPOCH"))%>%
47+
timing_variables = c("VISITDY", "EPOCH"),
48+
print_messages = print_messages)%>%
4549
filter(
4650
(TIME == 1 & TIME_SOURCE == "VISITDY") |
4751
(TIME == "BASELINE" & TIME_SOURCE == "EPOCH")
@@ -61,7 +65,8 @@ create_participant_table <- function(dm_domain,
6165
left_join(
6266
prepare_domain(vs_domain, "vs",
6367
variables_include = c("HEIGHT", "WEIGHT", "BMI", "MUARMCIR"),
64-
timing_variables = c("VISITDY", "EPOCH")) %>%
68+
timing_variables = c("VISITDY", "EPOCH"),
69+
print_messages = print_messages) %>%
6570
filter(
6671
(TIME == 1 & TIME_SOURCE == "VISITDY") |
6772
(TIME == "BASELINE" & TIME_SOURCE == "EPOCH")
@@ -81,7 +86,8 @@ create_participant_table <- function(dm_domain,
8186
left_join(
8287
prepare_domain(lb_domain, "lb",
8388
variables_include = c("G6PD"),
84-
timing_variables = c("VISITDY", "EPOCH")) %>%
89+
timing_variables = c("VISITDY", "EPOCH"),
90+
print_messages = print_messages) %>%
8591
filter(
8692
(TIME == 1 & TIME_SOURCE == "VISITDY") |
8793
(TIME == "BASELINE" & TIME_SOURCE == "EPOCH")
@@ -101,7 +107,8 @@ create_participant_table <- function(dm_domain,
101107
left_join(
102108
prepare_domain(mb_domain, "mb",
103109
variables_include = c("HIV"),
104-
timing_variables = c("VISITDY", "EPOCH")) %>%
110+
timing_variables = c("VISITDY", "EPOCH"),
111+
print_messages = print_messages) %>%
105112
filter(
106113
(TIME == 1 & TIME_SOURCE == "VISITDY") |
107114
(TIME == "BASELINE" & TIME_SOURCE == "EPOCH")
@@ -121,7 +128,8 @@ create_participant_table <- function(dm_domain,
121128
left_join(
122129
prepare_domain(rp_domain, "rp",
123130
variables_include = c("PREGIND", "EGESTAGE"),
124-
timing_variables = c("VISITDY", "EPOCH")) %>%
131+
timing_variables = c("VISITDY", "EPOCH"),
132+
print_messages = print_messages) %>%
125133
filter(
126134
(TIME == 1 & TIME_SOURCE == "VISITDY") |
127135
(TIME == "BASELINE" & TIME_SOURCE == "EPOCH")

R/iddoverse-package.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#' @importFrom dplyr last
2020
#' @importFrom dplyr left_join
2121
#' @importFrom dplyr mutate
22+
#' @importFrom dplyr n
2223
#' @importFrom dplyr relocate
2324
#' @importFrom dplyr rename
2425
#' @importFrom dplyr right_join

0 commit comments

Comments
 (0)