Skip to content

Commit

Permalink
address NA counts in prepare_ae_specific
Browse files Browse the repository at this point in the history
  • Loading branch information
LittleBeannie committed Jul 26, 2023
1 parent 0536f4f commit 15f6f76
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions R/prepare_ae_specific.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 15f6f76

Please sign in to comment.