mirror of
https://github.com/agdamsbo/REDCapCAST.git
synced 2024-11-24 22:11:55 +01:00
Compare commits
No commits in common. "635fa2f091a4ef963549f513ac5b5dcf058a042e" and "8199ec6663ffd5ceed22fb084adfd4d3e5281ada" have entirely different histories.
635fa2f091
...
8199ec6663
@ -51,13 +51,17 @@ Imports:
|
|||||||
keyring,
|
keyring,
|
||||||
purrr,
|
purrr,
|
||||||
readr,
|
readr,
|
||||||
stats
|
stats,
|
||||||
|
calendar,
|
||||||
|
lubridate,
|
||||||
|
glue
|
||||||
Collate:
|
Collate:
|
||||||
'utils.r'
|
'utils.r'
|
||||||
'process_user_input.r'
|
'process_user_input.r'
|
||||||
'REDCap_split.r'
|
'REDCap_split.r'
|
||||||
'ds2dd.R'
|
'ds2dd.R'
|
||||||
'ds2dd_detailed.R'
|
'ds2dd_detailed.R'
|
||||||
|
'ds2ical.R'
|
||||||
'easy_redcap.R'
|
'easy_redcap.R'
|
||||||
'read_redcap_instrument.R'
|
'read_redcap_instrument.R'
|
||||||
'read_redcap_tables.R'
|
'read_redcap_tables.R'
|
||||||
|
@ -5,6 +5,7 @@ export(clean_redcap_name)
|
|||||||
export(d2w)
|
export(d2w)
|
||||||
export(ds2dd)
|
export(ds2dd)
|
||||||
export(ds2dd_detailed)
|
export(ds2dd_detailed)
|
||||||
|
export(ds2ical)
|
||||||
export(easy_redcap)
|
export(easy_redcap)
|
||||||
export(focused_metadata)
|
export(focused_metadata)
|
||||||
export(get_api_key)
|
export(get_api_key)
|
||||||
|
3
NEWS.md
3
NEWS.md
@ -14,6 +14,8 @@
|
|||||||
|
|
||||||
* NEW: `read_redcap_instrument()` convenience function to retrieve complete instrument. Goes a little against the focused approach. DETAILED INSTRUCTION IS PENDING.
|
* NEW: `read_redcap_instrument()` convenience function to retrieve complete instrument. Goes a little against the focused approach. DETAILED INSTRUCTION IS PENDING.
|
||||||
|
|
||||||
|
* NEW: `ds2ical()` converts data set to ical format with easy glue string for summary and description. Export .ics file with `calendar::ic_write()`.
|
||||||
|
|
||||||
### Other
|
### Other
|
||||||
|
|
||||||
I believe `renv` has now been added and runs correctly. After clone, do `renv::restore()` to install all necessary package to modify the package.
|
I believe `renv` has now been added and runs correctly. After clone, do `renv::restore()` to install all necessary package to modify the package.
|
||||||
@ -24,7 +26,6 @@ I believe `renv` has now been added and runs correctly. After clone, do `renv::r
|
|||||||
|
|
||||||
* Tests for `ds2dd_detailed()`
|
* Tests for `ds2dd_detailed()`
|
||||||
|
|
||||||
* Tests for new functions.
|
|
||||||
|
|
||||||
# REDCapCAST 24.1.1
|
# REDCapCAST 24.1.1
|
||||||
|
|
||||||
|
58
R/ds2ical.R
Normal file
58
R/ds2ical.R
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
utils::globalVariables(c("DTSTART"))
|
||||||
|
|
||||||
|
#' Convert data set to ical file
|
||||||
|
#'
|
||||||
|
#' @param data data set
|
||||||
|
#' @param start dplyr style event start datetime column name
|
||||||
|
#' @param end dplyr style event end datetime column name
|
||||||
|
#' @param location dplyr style event location column name
|
||||||
|
#' @param summary.glue.string character string to pass to glue::glue() for event
|
||||||
|
#' name (summary). Can take any column from data set.
|
||||||
|
#' @param description.glue.string character string to pass to glue::glue() for
|
||||||
|
#' event description. Can take any column from data set.
|
||||||
|
#'
|
||||||
|
#' @return tibble of class "ical"
|
||||||
|
#' @export
|
||||||
|
#'
|
||||||
|
#' @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()
|
||||||
|
#' df |> ds2ical(summary.glue.string = "ID {id} [{assessor}] {note}")
|
||||||
|
#' # Export .ics file: (not run)
|
||||||
|
#' ical <- df |> ds2ical(start, end, location, description.glue.string = "{note}")
|
||||||
|
#' # ical |> calendar::ic_write(file=here::here("calendar.ics"))
|
||||||
|
ds2ical <- function(data,
|
||||||
|
start=start,
|
||||||
|
end=end,
|
||||||
|
location=location,
|
||||||
|
summary.glue.string = "ID {id} [{assessor}]",
|
||||||
|
description.glue.string = NULL) {
|
||||||
|
ds <- data |>
|
||||||
|
dplyr::transmute(
|
||||||
|
SUMMARY = glue::glue(summary.glue.string, .na = ""),
|
||||||
|
DTSTART = lubridate::ymd_hms({{ start }}),
|
||||||
|
DTEND = lubridate::ymd_hms({{ end }}),
|
||||||
|
LOCATION = {{ location }}
|
||||||
|
)
|
||||||
|
|
||||||
|
if (!is.null(description.glue.string)){
|
||||||
|
ds <- dplyr::tibble(ds,
|
||||||
|
dplyr::transmute(data,
|
||||||
|
DESCRIPTION = glue::glue(
|
||||||
|
description.glue.string,
|
||||||
|
.na = ""
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
ds |>
|
||||||
|
(\(x){
|
||||||
|
x |>
|
||||||
|
dplyr::mutate(UID = replicate(nrow(x), calendar::ic_guid()))
|
||||||
|
})() |>
|
||||||
|
dplyr::filter(!is.na(DTSTART)) |>
|
||||||
|
calendar::ical()
|
||||||
|
}
|
46
man/ds2ical.Rd
Normal file
46
man/ds2ical.Rd
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
% Generated by roxygen2: do not edit by hand
|
||||||
|
% Please edit documentation in R/ds2ical.R
|
||||||
|
\name{ds2ical}
|
||||||
|
\alias{ds2ical}
|
||||||
|
\title{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{
|
||||||
|
\item{data}{data set}
|
||||||
|
|
||||||
|
\item{start}{dplyr style event start datetime column name}
|
||||||
|
|
||||||
|
\item{end}{dplyr style event end datetime column name}
|
||||||
|
|
||||||
|
\item{location}{dplyr style event location column name}
|
||||||
|
|
||||||
|
\item{summary.glue.string}{character string to pass to glue::glue() for event
|
||||||
|
name (summary). Can take any column from data set.}
|
||||||
|
|
||||||
|
\item{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"
|
||||||
|
}
|
||||||
|
\description{
|
||||||
|
Convert data set to ical file
|
||||||
|
}
|
||||||
|
\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()
|
||||||
|
df |> ds2ical(summary.glue.string = "ID {id} [{assessor}] {note}")
|
||||||
|
# Export .ics file: (not run)
|
||||||
|
ical <- df |> ds2ical(start, end, location, description.glue.string = "{note}")
|
||||||
|
# ical |> calendar::ic_write(file=here::here("calendar.ics"))
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user