Convert data set to ical file
Usage
ds2ical(
data,
start,
location,
summary.glue.string = "ID {id} [{assessor}]",
description.glue.string = NULL,
event.length = lubridate::hours(2)
)
Arguments
- data
data set
- start
event start column
- location
event location column
- 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.
- event.length
use lubridate functions to generate "Period" class element (default is lubridate::hours(2))
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"))
df |> ds2ical(start, location)
#> # A tibble: 2 × 5
#> SUMMARY DTSTART DTEND LOCATION UID
#> <glue> <dttm> <dttm> <chr> <chr>
#> 1 ID 1 [A] 2024-02-05 13:58:10 2024-02-05 15:58:10 111 ical-6058ef88-8df2-…
#> 2 ID 3 [A] 2024-02-07 13:58:10 2024-02-07 15:58:10 111 ical-8d9bc2f4-09ef-…
df |> ds2ical(start, location,
summary.glue.string = "ID {id} [{assessor}] {note}")
#> # A tibble: 2 × 5
#> SUMMARY DTSTART DTEND LOCATION UID
#> <glue> <dttm> <dttm> <chr> <chr>
#> 1 ID 1 [A] 2024-02-05 13:58:10 2024-02-05 15:58:10 111 ical-8be1a95c-5…
#> 2 ID 3 [A] OBS 2024-02-07 13:58:10 2024-02-07 15:58:10 111 ical-5a05f23b-f…
# Export .ics file: (not run)
ical <- df |> ds2ical(start, location, description.glue.string = "{note}")
# ical |> calendar::ic_write(file=here::here("calendar.ics"))