Learn R Programming

admiralvaccine (version 0.6.0)

max_flag: Creating Maximum Flag

Description

To Flag the maximum records depends on the grouping variables in a flag variable.

Usage

max_flag(dataset, by_vars, fl)

Value

Data frame with flag variable which is flagged for the maximum value records depending on the variables passed in by_vars by user.

Arguments

dataset

Input dataset

by_vars

By variables which goes to group by, to create the flag. Pass the variables inside the exprs().

fl

Flag variable name, Pass it as string.

Author

Dhivya Kanagaraj

Examples

Run this code

library(tibble)
library(admiral)

input <- tribble(
  ~USUBJID, ~FAOBJ, ~FATESTCD, ~FATPTREF, ~AVAL, ~FATPT, ~PARAMCD,
  "ABC101", "REDNESS", "DIAMETER", "VACC 1", 10, "DAY 1", "DIARE",
  "ABC101", "REDNESS", "DIAMETER", "VACC 1", 7, "DAY 2", "DIARE",
  "ABC101", "REDNESS", "DIAMETER", "VACC 2", 3, "DAY 1", "DIARE",
  "ABC101", "REDNESS", "DIAMETER", "VACC 2", 8, "DAY 2", "DIARE",
  "ABC101", "FATIQUE", "SEV", "VACC 1", 1, "DAY 1", "SEVFAT",
  "ABC101", "FATIQUE", "SEV", "VACC 1", 1, "DAY 2", "SEVFAT",
  "ABC101", "FATIQUE", "SEV", "VACC 2", 2, "DAY 1", "SEVFAT",
  "ABC101", "FATIQUE", "SEV", "VACC 2", 3, "DAY 2", "SEVFAT"
)

max_flag(
  dataset = input,
  by_vars = exprs(USUBJID, FAOBJ, FATPTREF, PARAMCD),
  fl = "ANL01FL"
)

Run the code above in your browser using DataLab