Skip to contents

# Convert data set to ical file

Source: `R/ds2ical.R`
`ds2ical.Rd`

Convert data set to ical file

## Usage

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

## Arguments

data

  data set

start

  dplyr style event start datetime column name

end

  dplyr style event end datetime column name

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 × 5
    #>   SUMMARY  DTSTART             DTEND               LOCATION UID
    #>   <glue>   <dttm>              <dttm>              <chr>    <chr>
    #> 1 ID 1 [A] 2024-02-07 09:20:36 2024-02-07 11:20:36 111      ical-6058ef88-8df2-…
    #> 2 ID 3 [A] 2024-02-09 09:20:36 2024-02-09 11:20:36 111      ical-8d9bc2f4-09ef-…
    df |> ds2ical(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-07 09:20:36 2024-02-07 11:20:36 111      ical-8be1a95c-5…
    #> 2 ID 3 [A] OBS 2024-02-09 09:20:36 2024-02-09 11:20:36 111      ical-5a05f23b-f…
    # Export .ics file: (not run)
    ical <- df |> ds2ical(start, end, location, description.glue.string = "{note}")
    # ical |> calendar::ic_write(file=here::here("calendar.ics"))