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.
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-02-09 08:30:23 2024-02-09 10:30:23 ical-09ef2f83-9eba-4d1f-a8af…
#> 2 ID 3 [A] 2024-02-11 08:30:23 2024-02-11 10:30:23 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-02-09 08:30:23 2024-02-09 10:30:23 ical-f0535f7e-0c5a-4ea6-…
#> 2 ID 3 [A] OBS 2024-02-11 08:30:23 2024-02-11 10:30:23 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"))