chooseDate: Choose date based on 'earlier' flag.

Description Usage Arguments Details Value Examples

View source: R/chooseDate.R

Description

Part of Pedigree Curation

Usage

1
chooseDate(d1, d2, earlier = TRUE)

Arguments

d1

Date vector with the first of two dates to compare.

d2

Date vector with the second of two dates to compare.

earlier

logical variable with TRUE if the earlier of the two dates is to be returned, otherwise the later is returned. Default is TRUE.

Details

Given two dates, one is selected to be returned based on whether it occurred earlier or later than the other. NAs are ignored if possible.

Value

Date vector of chosen dates or NA where neither is provided

Examples

1
2
3
4
5
6
7
8
library(nprcgenekeepr)
someDates <- lubridate::mdy(paste0(sample(1:12, 2, replace = TRUE), "-",
                                   sample(1:28, 2, replace = TRUE), "-",
                                   sample(seq(0, 15, by = 3), 2,
                                          replace = TRUE) + 2000))
someDates
chooseDate(someDates[1], someDates[2], earlier = TRUE)
chooseDate(someDates[1], someDates[2], earlier = FALSE)

rmsharp/nprcmanager documentation built on April 24, 2021, 3:13 p.m.