Calendar

knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(toastui)

Usage

Create interactive calendars with:

calendar()

You can display calendars in interactive R Markdown documents or Shiny applications:

Monthly calendar

Create a monthly calendar:

calendar(cal_demo_data(), navigation = TRUE, defaultDate = Sys.Date()) %>%
  cal_month_options(
    startDayOfWeek  = 1, 
    narrowWeekend = TRUE
  ) %>% 
  cal_props(cal_demo_props())

Weekly calendar

Create a weekly calendar:

calendar(cal_demo_data("week"), view = "week", defaultDate = Sys.Date()) %>% 
  cal_week_options(
    startDayOfWeek = 1,
    workweek = TRUE
  ) %>% 
  cal_props(cal_demo_props())

Schedules

To add schedules into a calendar who can pass a data.frame as first argument to calendar(), or use cal_schedules() :

# Define directly schedules properties
calendar() %>%
  cal_schedules(
    title = "My schedule",
    start = format(Sys.Date(), "%Y-%m-03 00:00:00"),
    end = format(Sys.Date(), "%Y-%m-17 00:00:00")
  )

# Or you can use a data.frame
my_calendar_data <- data.frame(
  title = "My schedule",
  start = format(Sys.Date(), "%Y-%m-03 00:00:00"),
  end = format(Sys.Date(), "%Y-%m-17 00:00:00")
)
calendar() %>%
  cal_schedules(
    my_calendar_data
  )

Properties for schedules are described in table below:

datagrid(schedules_properties) %>% 
  grid_columns(
    column = "Name", 
    width = 150,
    renderer = list(
      styles = list(
        fontWeight = "bold"
      )
    )
  ) %>% 
  grid_columns(
    column = "Type", 
    width = 150
  )

Calendar properties

Calendar properties can be used to set common appearance to a group of schedules with the same calendarId.

calendar() %>%
  cal_schedules(
    title = "My schedule",
    calendarId = 123, # <-- set a calendarId
    start = format(Sys.Date(), "%Y-%m-03 00:00:00"),
    end = format(Sys.Date(), "%Y-%m-17 00:00:00")
  ) %>% 
  cal_props(
    id = 123, # <-- reference to schedules' calendarId
    name = "My Calendar",
    color = "white",
    backgroundColor = "darkorange",
    borderColor = "darkorange"
  )

Properties for calendars are described in table below:

datagrid(calendar_properties, bodyHeight = "auto") %>% 
  grid_columns(
    column = "Name", 
    width = 150,
    renderer = list(
      styles = list(
        fontWeight = "bold"
      )
    )
  ) %>% 
  grid_columns(
    column = "Type", 
    width = 150
  )


Try the toastui package in your browser

Any scripts or data that you put into this service are public.

toastui documentation built on April 4, 2025, 1:57 a.m.