
Generate data frame of records that exist each year
exist_at_date.RdThis function calculates which items in a collection are existing at a given date (or dates).
Usage
exist_at_date(
date,
AccessionYear,
ItemStatusDate,
ItemStatusType,
post_date = as.character(Sys.Date())
)Arguments
- date
dates in the format
YYYY-MM-DDorYYYY/MM/DD.- AccessionYear
The accession year of the records.
- ItemStatusDate
The data when the records were last updated.
- ItemStatusType
The status of the record when last updated. Either
ExistingorNotExisting.- post_date
Set the date that existing plants in the LC are classed as alive until . Default is the present day.
Value
data frame where each column corresponds to a date, each row an item in the collection. The (i,j)th value is a logical (TRUE/FALSE) corresponding whether the ith item existed at the jth date.
Details
Accession date is inputted through AccessionYear which accepts only the year, for example c(2014,2017,2015). The accession date is then set to the 1st of January in the given year.
Item death is calculated via the inputs ItemStatusDate and ItemStatusType. If the item is still alive (ItemStatusType == 'Existing) then the death date is set to today (Sys.Date()). Otherwise the item is dead (ItemStatusType == 'NotExisting) and we use the corresponding date given in ItemStatusDate. If only the year is available in ItemStatusDate we set the date of death to the 31st of December that year. If only the month and year is available we set the day of the item death to be the 28th.
AccessionYear, ItemStatusDate and ItemStatusType inputs must have the same length and the ith value in each corresponds to the ith item in the collection.
Examples
exist_at_date(date = c('2003-06-25', '2010-03-07'),
AccessionYear = c('1956', '1988', '2005', '2018'),
ItemStatusDate = c('2004-01', '2010-03-05', '2022-04-08', '2022-08-19'),
ItemStatusType = c('NotExisting','NotExisting','Existing','Existing'))
#> 2003-06-25 2010-03-07
#> 1 TRUE FALSE
#> 2 TRUE FALSE
#> 3 FALSE TRUE
#> 4 FALSE FALSE