Compute a vector of numeric sample times from labels in a sequence aligment or phylogeny
sampleYearsFromLabels(tips, dateFormat = "%Y-%m-%d", delimiter = NULL, index = NULL, regex = NULL)
tips
: A character vector supplying the name of each sampledateFormat
: The format of the sample date. See ?Date for more informationdelimiter
: Character(s) which separate data in each labelindex
: Integer position of the date string in each label with respect to delimiterregex
: A regular expression for finding the date substring. Should not be used with delimiter or indexNumeric vector with sample time in decimal format.
## A couple of labels for Ebola virus sequences: sampleYearsFromLabels( c('EBOV|AA000000|EM104|SierraLeone_EM|2014-06-02' , 'EBOV|AA000000|G3713|SierraLeone_G|2014-06-09') , delimiter='|' ) ## Equivalently: sampleYearsFromLabels( c('EBOV|AA000000|EM104|SierraLeone_EM|2014-06-02' , 'EBOV|AA000000|G3713|SierraLeone_G|2014-06-09') , regex='[0-9]+-[0-9]+-[0-9]+')
Useful links