Skip to contents

Convert data set to ical file

Usage

ds2ical(
  data,
  start = start,
  end = end,
  location = NULL,
  summary.glue.string = "ID {id} [{assessor}]",
  description.glue.string = NULL
)

Arguments

data

data set

start

dplyr style event start datetime column name. Data or datetime object.

end

dplyr style event end datetime column name. Data or datetime object.

location

dplyr style event location column name

summary.glue.string

character string to pass to glue::glue() for event name (summary). Can take any column from data set.

description.glue.string

character string to pass to glue::glue() for event description. Can take any column from data set.

Value

tibble of class "ical"

Examples

df <- dplyr::tibble(
  start = c(Sys.time(), Sys.time() + lubridate::days(2)),
  id = c("1", 3), assessor = "A", location = "111", note = c(NA, "OBS")
) |>
  dplyr::mutate(end = start + lubridate::hours(2))
df |> ds2ical()
#> # A tibble: 2 × 4
#>   SUMMARY  DTSTART             DTEND               UID                          
#>   <glue>   <dttm>              <dttm>              <chr>                        
#> 1 ID 1 [A] 2024-10-25 08:17:40 2024-10-25 10:17:40 ical-09ef2f83-9eba-4d1f-a8af…
#> 2 ID 3 [A] 2024-10-27 08:17:40 2024-10-27 10:17:40 ical-55943cb0-3cfd-43a0-9ffc…
df |> ds2ical(summary.glue.string = "ID {id} [{assessor}] {note}")
#> # A tibble: 2 × 4
#>   SUMMARY      DTSTART             DTEND               UID                      
#>   <glue>       <dttm>              <dttm>              <chr>                    
#> 1 ID 1 [A]     2024-10-25 08:17:40 2024-10-25 10:17:40 ical-f0535f7e-0c5a-4ea6-…
#> 2 ID 3 [A] OBS 2024-10-27 08:17:40 2024-10-27 10:17:40 ical-2c246f66-2ec6-4b0d-…
# Export .ics file: (not run)
ical <- df |> ds2ical(start, end, location,
description.glue.string = "{note}")
# ical |> calendar::ic_write(file=here::here("calendar.ics"))