Learn R Programming

pregnancy (version 0.2.1)

medications-option: 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()

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

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.

See Also

  • medications_remaining(), medications

Examples

Run this code
# 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)

Run the code above in your browser using DataLab