trim_levels_to_map()
Helper function to create a map data frame from the input dataset, which can be used as an argument in the
trim_levels_to_map
split function. Based on different method, the map is constructed differently.
h_map_for_count_abnormal(
df,
variables = list(anl = "ANRIND", split_rows = c("PARAM"), range_low = "ANRLO",
range_high = "ANRHI"),
abnormal = list(low = c("LOW", "LOW LOW"), high = c("HIGH", "HIGH HIGH")),
method = c("default", "range"),
na_str = ""
)
A map data.frame
.
(data.frame
)
data set containing all analysis variables.
(named list
of string
)
list of additional analysis variables.
(named list
)
identifying the abnormal range level(s) in df
. Based on the levels of
abnormality of the input dataset, it can be something like list(Low = "LOW LOW", High = "HIGH HIGH")
or
abnormal = list(Low = "LOW", High = "HIGH"))
(string
)
indicates how the returned map will be constructed. Can be "default"
or "range"
.
(string
)
string used to replace all NA
or empty values in the output.
adlb <- df_explicit_na(tern_ex_adlb)
h_map_for_count_abnormal(
df = adlb,
variables = list(anl = "ANRIND", split_rows = c("LBCAT", "PARAM")),
abnormal = list(low = c("LOW"), high = c("HIGH")),
method = "default",
na_str = ""
)
df <- data.frame(
USUBJID = c(rep("1", 4), rep("2", 4), rep("3", 4)),
AVISIT = c(
rep("WEEK 1", 2),
rep("WEEK 2", 2),
rep("WEEK 1", 2),
rep("WEEK 2", 2),
rep("WEEK 1", 2),
rep("WEEK 2", 2)
),
PARAM = rep(c("ALT", "CPR"), 6),
ANRIND = c(
"NORMAL", "NORMAL", "LOW",
"HIGH", "LOW", "LOW", "HIGH", "HIGH", rep("NORMAL", 4)
),
ANRLO = rep(5, 12),
ANRHI = rep(20, 12)
)
df$ANRIND <- factor(df$ANRIND, levels = c("LOW", "HIGH", "NORMAL"))
h_map_for_count_abnormal(
df = df,
variables = list(
anl = "ANRIND",
split_rows = c("PARAM"),
range_low = "ANRLO",
range_high = "ANRHI"
),
abnormal = list(low = c("LOW"), high = c("HIGH")),
method = "range",
na_str = ""
)
Run the code above in your browser using DataLab