Description Usage Arguments Details Value
This function extracts a date from the name of a file.
1 2 | extract_date_from_file_name(file_name, date_format = "ymd",
date_match_position = 1)
|
file_name |
name of the file. Character |
date_format |
Date format. Should match a lubridate standard format. Character |
date_match_position |
See notes above. |
Assumptions: 1. Date is in the name of the file. 2. Date is in the following format: dddddddd where d is an integer. 3. Date is the first 8 digits matched in the filename. Optionally you can set this to be the ith match by setting the match_position parameter to i. See notes below.
Example: file_name = "file1_20150202_312314342_20150802.nc" date_format = "ymd" Returns "20150202"
Notes: 1. Note that the function by default returns the first 8 digits sequence it encounters in the filename (starting left to right). The argument match_position can be used to access other dates. For instance match_position = 2 matches the second date (or, better, 8 digits sequence) it finds. 2. Note that date format can be set (should it vary). 3. If the date_format is not correct a NA is returned
an object of class Date.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.