knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  out.width = "100%"
)
library(daily)
library(dplyr)

Overview

The primary use case consists of three steps

  1. Create a daily file (a text file with simple markup)
  2. Convert the daily file into a data frame with daily2cal()
  3. Render the calendar as HTML or ggplot.

Steps 2 and 3 can be combined into a single step.

Step 1: Daily files

Calendar information can be culled from a "daily file" with with following structure.

Example daily file

Here is an example daily file (rendered below).

system.file("daily.txt", package = "daily") %>%
  readLines() %>%
  paste(collapse = "\n") %>%
  cat() 

Step 2: Converting to a data frame

daily2cal() converts the daily file into a data frame. To use your own daily file, replace the path argument below with the path to your daily file.

library(daily)
library(dplyr)
cal <-
  daily2cal(
    path  = system.file("daily.txt", package = "daily")
  ) 
glimpse(cal)

Each time a bare === is encountered, the calendar is advanced to the next default day (see options below). If a date is specified, it is used, regardless of which days are default days.

Step 3: Rendering a calendar

The calendar can be rendered as HTML or as a ggplot. The show argument determines which days are displayed (Sunday = 1, Saturday = 7).

calendar_css() %>% cat()
cal %>% html_calendar(show = 2:6) %>% cat()
cal %>% gg_calendar(show = 2:6, size = 4)

Alternatively, the daily file can be converted directly to HTML using daily2html():

daily2html(path  = system.file("daily.txt", package = "daily")) %>% cat()

Options

The following options may be specified as arguments to daily2cal() or as part of the YAML header of the daily file. Arguments take precedence over the YAML header.

Other elements of the YAML header are ignored currently, but can be used to record information about your calendar.



rpruim/calendar documentation built on April 24, 2023, 8:41 a.m.