medications-option: Set or get the 'pregnancy.medications' option

medications-optionR Documentation

Set or get the pregnancy.medications option

Description

Functions to get and set the default medications data frame used in the medications_remaining() function. Settings persist for the current R session only, unless added to .Rprofile. set_medications() sets the "pregnancy.medications" option and get_medications() retrieves it.

Usage

set_medications(meds)

get_medications()

Arguments

meds

Data frame containing medication schedule. Must have the following columns:

  • medication (character/factor): Name of the medication

  • format (character/factor): Format of the medication (e.g., pill, injection)

  • quantity (numeric): Number of units to take per day

  • start_date (Date or character string representing a date, e.g. "YYYY-MM-DD"): Date to start taking the medication

  • stop_date (Date or character string representing a date, e.g. "YYYY-MM-DD"): Final date on which the medication is taken

If NULL, will try to use the "pregnancy.medications" option. Required if option not set.

Value

Both functions invisibly return the current medications setting:

  • get_medications() returns the current setting (a data frame) or NULL if not set

  • set_medications() returns the medications data frame that was set

See Also

  • medications_remaining(), medications

Examples

# Store original setting (without messages)
original_medications <- getOption("pregnancy.medications")

# Set the option
set_medications(pregnancy::medications)

# Get the option
get_medications()

# Restore original setting (without messages)
options(pregnancy.medications = original_medications)


pregnancy documentation built on Sept. 14, 2025, 5:09 p.m.