Learn R Programming

metalite (version 0.1.4)

n_subject: Count number of unique subjects

Description

Count number of unique subjects

Usage

n_subject(
  id,
  group,
  par = NULL,
  na = "Missing",
  use_na = c("ifany", "no", "always")
)

Value

A data frame summarizing the number of unique subjects in different arms.

Arguments

id

A character vector of subject identifier.

group

A factor vector of group name.

par

A character vector of parameter name.

na

A character string used to label missing values. Defaults to "Missing".

use_na

A character value for whether to include NA values in the table. See the useNA argument in base::table() for more details.

Examples

Run this code
library(r2rtf)

r2rtf_adae$TRTA <- factor(r2rtf_adae$TRTA)
r2rtf_adae$SEX[1:5] <- NA

n_subject(r2rtf_adae$USUBJID, r2rtf_adae$TRTA)
n_subject(r2rtf_adae$USUBJID, r2rtf_adae$TRTA, r2rtf_adae$SEX)
n_subject(r2rtf_adae$USUBJID, r2rtf_adae$TRTA, r2rtf_adae$SEX, use_na = "always")
n_subject(r2rtf_adae$USUBJID, r2rtf_adae$TRTA, r2rtf_adae$SEX, na = "Null")

Run the code above in your browser using DataLab