--- title: "Checking the Cache" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{Checking the Cache} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- ```{r setup, include = FALSE} knitr::opts_chunk$set( collapse = TRUE, comment = "#>", out.width = "100%" ) show <- function(x) cat(x$output, sep = "\n") ``` ```{r load-used-data, echo=FALSE} load("data_doctor.RData") ``` ## Introduction rb3 keeps everything it downloads in a local cache: the raw files, the datasets built from them, and one download record (a *meta*) per file, in `meta.sqlite`. Over time you fetch some dates, skip others, and some downloads fail. `rb3_doctor()` tells you how healthy that cache is, and above all whether the time series behind a dataset is complete: - which business days have no data in a dataset layer, and **why** each one is missing; - which download records are stale or broken. `rb3_doctor()` only reports. It never downloads, deletes or rewrites anything. You decide what to do with what it finds, usually by calling `fetch_marketdata()` again. ```{r packages, message=FALSE} library(rb3) library(dplyr) library(bizdays) ``` ## What the doctor checks `rb3_doctor()` has two kinds of checks. The **gap check** runs when you pass a template. It looks at one dataset layer of that template (`input` or `staging`), takes every `refdate` in it, and compares them with the business days of a calendar. Each business day without rows is a gap. The **health checks** always run, on the whole cache (`rb3_doctor()`) or on the records of one template (`rb3_doctor("