Skip to content

Commit 1a1048b

Browse files
authored
Merge pull request #23 from Boehringer-Ingelheim/273711_fix_info_labels_not_displaying
fix patient info labels for data.frame input
2 parents 0caa781 + 065584f commit 1a1048b

4 files changed

Lines changed: 16 additions & 2 deletions

File tree

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: dv.papo
22
Title: Patient Profile
3-
Version: 2.0.3-900
3+
Version: 2.0.4-900
44
Date: 2024-08-13
55
Authors@R:
66
c(person("Boehringer-Ingelheim Pharma GmbH & Co.KG", role = c("cph", "fnd")),

NEWS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# dv.papo 2.0.4-900
2+
- Fixes issue with labels not working fully if a data.frame is passed as input.
3+
14
# dv.papo 2.0.3-900
25
- Fixes y-axis getting squashed if blank values present in DECODE variable for AE/CM plots.
36

R/data_prep.R

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@ pt_info_data_filter <- function(df, subjid_var, columns, selected_key) {
1313
row_index <- which(df[[subjid_var]] == selected_key)
1414
if (length(row_index) == 1) {
1515
res <- df[row_index, columns]
16+
df_labels <- structure(get_labels(df), names = names(df))[columns] #extract and save labels
17+
for (i in columns) {
18+
attr(res[[i]], "label") <- df_labels[[i]] # re-apply saved labels
19+
}
1620
}
17-
1821
return(res)
1922
}
2023

tests/testthat/test-data_prep.R

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
test_that("pt_info_data_filter preserves data.frame labels", {
2+
df <- as.data.frame(safetyData::adam_adsl)
3+
expected_labels <- get_labels(df)
4+
output <- pt_info_data_filter(
5+
df, subjid_var = "USUBJID", columns = names(df), selected_key = "01-701-1015"
6+
)
7+
testthat::expect_identical(get_labels(output), expected_labels)
8+
})

0 commit comments

Comments
 (0)