From 15f6f76f5ac84c05326b5d50cee92159b8b3f596 Mon Sep 17 00:00:00 2001 From: "Zhao, Yujie" Date: Wed, 26 Jul 2023 14:54:09 -0400 Subject: [PATCH] address NA counts in `prepare_ae_specific` --- R/prepare_ae_specific.R | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/R/prepare_ae_specific.R b/R/prepare_ae_specific.R index ee47dac..83ea9ad 100644 --- a/R/prepare_ae_specific.R +++ b/R/prepare_ae_specific.R @@ -147,7 +147,8 @@ prepare_ae_specific <- function(meta, # Define SOC section if ("soc" %in% components && nrow(obs) > 0) { - soc_n <- metalite::n_subject(obs[[obs_id]], obs[[obs_group]], obs[[par_soc]]) + soc_n <- metalite::n_subject(obs[[obs_id]], obs[[obs_group]], obs[[par_soc]], + na = "NULL", use_na = "always") soc_n[[par_soc]] <- soc_n$name soc_n[[par_var]] <- soc_n$name @@ -161,11 +162,13 @@ prepare_ae_specific <- function(meta, if ("par" %in% components && nrow(obs) > 0) { u_soc <- unique(obs[order(obs[[par_soc]]), c(par_soc, par_var)]) - par_n <- metalite::n_subject(obs[[obs_id]], obs[[obs_group]], obs[[par_var]]) + par_n <- metalite::n_subject(obs[[obs_id]], obs[[obs_group]], obs[[par_var]], + na = "NULL", use_na = "always") par_n[[par_var]] <- par_n$name par_n <- merge(u_soc, par_n, all.y = TRUE) par_n$order <- 1e3 * as.numeric(factor(par_n[[par_soc]])) + seq_len(nrow(par_n)) + par_n$order[is.na(par_n$order)] <- max(soc_n$order) + 1 par_n$name <- to_sentence(par_n$name) } else { par_n <- NULL