file_sizes: Extract file sizes for HSMR Excel tables

View source: R/file_sizes.R

file_sizesR Documentation

Extract file sizes for HSMR Excel tables

Description

file_sizes takes the final date for which SMR data are included in the current publication and the filepath to the location of the HSMR Excel tables. It returns a character vector containing the size of each table.

Usage

file_sizes(end_date, filepath = here::here("data", "output"))

Arguments

end_date

The cut-off date for data to be included in the current HSMR publication, supplied with Date class. Must be the final day of either March, June, September or December. Must not be prior to 2019-03-31, as this is the extract end date for the 2019-08-13 publication. The current format of the HSMR Excel tables was first created for this publication. If an extract end date later than that of the current publication is supplied, the function will return an error.

filepath

A character string containing the filepath to the location of the HSMR Excel tables. Errors if not provided with a valid filepath. Defaults to here::here("data", "output").

Details

There are three HSMR Excel tables: tables 1, 2 and 3. If fewer or more Excel tables which follow the same naming conventions as tables 1, 2 and 3 are found in the filepath, the function will return an error.

File sizes are returned in kilobytes (KB) or megabytes (MB). A kilobyte is taken to be 1,024 bytes, and a megabyte to be 1,024 kilobytes.

Value

A character vector.

See Also

The code which creates this function uses regular expressions. For more information on using regular expressions, see this Jumping Rivers blog post and this vignette from the stringr package.

Examples

extract_end_date <- lubridate::dmy(31032019)

file_sizes(end_date = extract_end_date)
file_sizes(end_date = extract_end_date, filepath = getwd())[1]


Public-Health-Scotland/hsmr documentation built on June 24, 2024, 1:48 a.m.