|
1 | 1 | #' Tabulate function to display variables in a given domain |
2 | 2 | #' |
3 | | -#' Uses table() to display the variables contained within an SDTM |
4 | | -#' formatted data frame. Additionally can be split by STUDYID to display the |
5 | | -#' options across multiple studies. |
| 3 | +#' Uses table() to display the variables contained within an SDTM formatted data |
| 4 | +#' frame. Additionally can be split by STUDYID to display the options across |
| 5 | +#' multiple studies. |
6 | 6 | #' |
7 | | -#' @param domain Character. The two letter code for the domain which matches the data. |
8 | | -#' Character string. Domains included: "DM", "LB", "RP", "MB", "MP", "SA", |
9 | | -#' "IN", "VS", "DS", "RS", "PO", "SC", "HO", "ER" & "DD". |
| 7 | +#' @param domain Character. The two letter code for the domain which matches the |
| 8 | +#' data. |
| 9 | +#' Domains included: "DM", "LB", "RP", "MB", "MP", "SA", "IN", "VS", |
| 10 | +#' "DS", "RS", "PO", "SC", "HO", "ER", "DD", "PF", "AU", "PC", "PE". |
10 | 11 | #' @param data Domain data frame. |
11 | 12 | #' @param by_STUDYID Boolean. Split data by STUDYID if TRUE. Default is FALSE. |
12 | 13 | #' |
@@ -36,25 +37,33 @@ table_variables <- function(domain, data, by_STUDYID = FALSE) { |
36 | 37 | } else if (domain == "MP") { |
37 | 38 | return(table(data$MPLOC, useNA = "ifany")) |
38 | 39 | } else if (domain == "SA") { |
39 | | - return(table(str_to_upper(data$SATERM), useNA = "ifany")) ### |
| 40 | + return(table(str_to_upper(data$SATERM), useNA = "ifany")) |
40 | 41 | } else if (domain == "IN") { |
41 | | - return(table(str_to_upper(data$INTRT), useNA = "ifany")) ### |
| 42 | + return(table(str_to_upper(data$INTRT), useNA = "ifany")) |
42 | 43 | } else if (domain == "VS") { |
43 | 44 | return(table(data$VSTESTCD, useNA = "ifany")) |
44 | 45 | } else if (domain == "DS") { |
45 | | - return(table(data$DSDECOD, useNA = "ifany")) ### |
| 46 | + return(table(data$DSDECOD, useNA = "ifany")) |
46 | 47 | } else if (domain == "RS") { |
47 | 48 | return(table(data$RSTESTCD, useNA = "ifany")) |
48 | 49 | } else if (domain == "PO") { |
49 | | - return(table(str_to_upper(data$POTERM), useNA = "ifany")) ### |
| 50 | + return(table(str_to_upper(data$POTERM), useNA = "ifany")) |
50 | 51 | } else if (domain == "SC") { |
51 | 52 | return(table(data$SCTESTCD, useNA = "ifany")) |
52 | 53 | } else if (domain == "HO") { |
53 | | - return(table(data$HOTERM, useNA = "ifany")) ### |
| 54 | + return(table(data$HOTERM, useNA = "ifany")) |
54 | 55 | } else if (domain == "ER") { |
55 | | - return(table(data$ERTERM, useNA = "ifany")) ### |
| 56 | + return(table(data$ERTERM, useNA = "ifany")) |
56 | 57 | } else if (domain == "DD") { |
57 | | - return(table(data$DDTEST, useNA = "ifany")) |
| 58 | + return(table(data$DDTESTCD, useNA = "ifany")) |
| 59 | + } else if (domain == "PF") { |
| 60 | + return(table(data$PFTESTCD, useNA = "ifany")) |
| 61 | + } else if (domain == "AU") { |
| 62 | + return(table(data$AUTESTCD, useNA = "ifany")) |
| 63 | + } else if (domain == "PC") { |
| 64 | + return(table(data$PCTESTCD, useNA = "ifany")) |
| 65 | + } else if (domain == "PE") { |
| 66 | + return(table(data$PETESTCD, useNA = "ifany")) |
58 | 67 | } else{ |
59 | 68 | warn(str_c(domain, " domain not included in table_variables() function.")) |
60 | 69 | } |
@@ -86,11 +95,19 @@ table_variables <- function(domain, data, by_STUDYID = FALSE) { |
86 | 95 | } else if (domain == "SC") { |
87 | 96 | return(table(data$STUDYID, data$SCTESTCD, useNA = "ifany")) |
88 | 97 | } else if (domain == "HO") { |
89 | | - return(table(data$STUDYID, data$HOTERM, useNA = "ifany")) ### |
| 98 | + return(table(data$STUDYID, data$HOTERM, useNA = "ifany")) |
90 | 99 | } else if (domain == "ER") { |
91 | | - return(table(data$STUDYID, data$ERTERM, useNA = "ifany")) ### |
| 100 | + return(table(data$STUDYID, data$ERTERM, useNA = "ifany")) |
92 | 101 | } else if (domain == "DD") { |
93 | 102 | return(table(data$STUDYID, data$DDTEST, useNA = "ifany")) |
| 103 | + } else if (domain == "PF") { |
| 104 | + return(table(data$STUDYID, data$PFTESTCD, useNA = "ifany")) |
| 105 | + } else if (domain == "AU") { |
| 106 | + return(table(data$STUDYID, data$AUTESTCD, useNA = "ifany")) |
| 107 | + } else if (domain == "PC") { |
| 108 | + return(table(data$STUDYID, data$PCTESTCD, useNA = "ifany")) |
| 109 | + } else if (domain == "PE") { |
| 110 | + return(table(data$STUDYID, data$PETESTCD, useNA = "ifany")) |
94 | 111 | } else{ |
95 | 112 | warn(str_c(domain, " domain not included in table_variables() function.")) |
96 | 113 | } |
|
0 commit comments