rk.lubridate: Date & Time Tools for RKWard

This package provides a suite of RKWard plugins that create a graphical user interface for the lubridate R package. It simplifies working with dates and times by providing tools for parsing, formatting, arithmetic, and interval analysis without memorizing format codes or function names.

Features / Included Plugins

This package installs a new submenu in RKWard: Data > Date and Time (lubridate).

Core Tools

Time Spans

Calculations

🌍 Internationalization

As of version 0.0.5, the interface is fully localized to match your RKWard language settings:

Requirements

  1. A working installation of RKWard.
  2. The R package lubridate.
    install.packages("lubridate")
    
  3. The R package devtools (for installation from source).

Installation

  1. Open R in RKWard.
  2. Run the following commands in the R console:
local({
  require(devtools)
  install_github("AlfCano/rk.lubridate", force = TRUE)
})
  1. Restart RKWard to ensure the new menu items appear correctly.

Usage & Examples

To test the calculation plugins, create the test_dates dataframe using the code below:

library(lubridate)
ref_int <- interval(ymd("2023-01-01"), ymd("2023-03-31"))

test_dates <- data.frame(
  id = 1:5,
  event_date = as.Date(c("2023-01-15", "2023-02-28", "2023-03-31", "2024-02-29", "2025-12-25")),
  q1_2023 = rep(ref_int, 5) # Quarter 1 2023 Interval
)

Example 1: Shift Dates (Add 1 Month)

  1. Navigate to Data > Date and Time (lubridate) > Calculations > Shift Dates.
  2. Select Date Object: test_dates$event_date.
  3. Operation: Add (+).
  4. Amount: 1.
  5. Unit: Months.
  6. Time Type: Period.
  7. Click Submit.
    • Result: Jan 15 becomes Feb 15. Feb 28 becomes Mar 28.

Example 2: Check Overlaps

  1. Navigate to Data > Date and Time (lubridate) > Calculations > Check Overlaps.
  2. Date Object: test_dates$event_date.
  3. Interval Object: test_dates$q1_2023.
  4. Click Submit.
    • Result: Returns TRUE for the dates in Jan, Feb, Mar 2023. Returns FALSE for 2024 and 2025.

Example 3: Align Dates (Rollback)

  1. Navigate to Data > Date and Time (lubridate) > Calculations > Align Dates.
  2. Date Object: test_dates$event_date.
  3. Action: Rollback (Last day of prev month).
  4. Click Submit.
    • Result: "2023-01-15" becomes "2022-12-31". Useful for aligning financial reports.

Author

Alfonso Cano Robles (alfonso.cano@correo.buap.mx)

Assisted by Gemini, a large language model from Google.