From 17a6d9e7ee427c61ed01d82cb0fd57a3083cbd74 Mon Sep 17 00:00:00 2001 From: Daniel Vartanian Date: Sat, 22 May 2021 22:48:33 -0300 Subject: [PATCH] Remove `__` from the examples sections --- R/assign_date.R | 18 ++++++++++----- R/convert.R | 21 ++++++++++++------ R/fd.R | 6 +++-- R/gu.R | 6 +++-- R/le_week.R | 15 ++++++++----- R/mctq-package.R | 2 +- R/ms.R | 22 ++++++++++-------- R/pretty_mctq.R | 6 +++-- R/qplot_walk.R | 15 ++++++++----- R/raw_data.R | 7 ++++-- R/round_time.R | 6 +++-- R/sd.R | 48 ++++++++++++++++++++++++++-------------- R/shortest_interval.R | 12 ++++++---- R/sjl.R | 28 ++++++++++++++--------- R/sloss_week.R | 12 ++++++---- R/so.R | 6 +++-- R/sum_time.R | 12 ++++++---- R/tbt.R | 6 +++-- man/assign_date.Rd | 18 ++++++++++----- man/convert.Rd | 21 ++++++++++++------ man/fd.Rd | 6 +++-- man/gu.Rd | 6 +++-- man/le_week.Rd | 15 ++++++++----- man/mctq-package.Rd | 1 + man/ms.Rd | 6 +++-- man/msf_sc.Rd | 12 ++++++---- man/napd.Rd | 6 +++-- man/pretty_mctq.Rd | 6 +++-- man/qplot_walk.Rd | 15 ++++++++----- man/raw_data.Rd | 7 ++++-- man/round_time.Rd | 6 +++-- man/sd.Rd | 6 +++-- man/sd24.Rd | 6 +++-- man/sd_overall.Rd | 15 ++++++++----- man/sd_week.Rd | 15 ++++++++----- man/shortest_interval.Rd | 12 ++++++---- man/sjl.Rd | 13 ++++++----- man/sjl_weighted.Rd | 15 ++++++++----- man/sloss_week.Rd | 12 ++++++---- man/so.Rd | 6 +++-- man/sum_time.Rd | 12 ++++++---- man/tbt.Rd | 6 +++-- 42 files changed, 325 insertions(+), 166 deletions(-) diff --git a/R/assign_date.R b/R/assign_date.R index d0710a8..c35b5ae 100644 --- a/R/assign_date.R +++ b/R/assign_date.R @@ -95,7 +95,8 @@ #' @export #' #' @examples -#' ## __ Scalar example __ +#' ## Scalar example +#' #' start <- hms::parse_hms("23:11:00") #' end <- hms::parse_hms("05:30:00") #' assign_date(start, end) @@ -111,20 +112,23 @@ #' assign_date(start, end) #' #> [1] NA--NA # Expected #' -#' ## __ Vector example __ +#' ## Vector example +#' #' start <- c(hms::parse_hm("09:45"), hms::parse_hm("20:30")) #' end <- c(hms::parse_hm("21:15"), hms::parse_hm("04:30")) #' assign_date(start, end) #' #> [1] 1970-01-01 09:45:00 UTC--1970-01-01 21:15:00 UTC # Expected #' #> [2] 1970-01-01 20:30:00 UTC--1970-01-02 04:30:00 UTC # Expected #' -#' ## __ To return `start` and `end` as interval (default)__ +#' ## To return `start` and `end` as interval (default) +#' #' start <- hms::parse_hm("12:34") #' end <- hms::parse_hm("01:25") #' assign_date(start, end) #' #> [1] 1970-01-01 12:34:00 UTC--1970-01-02 01:25:00 UTC # Expected #' -#' ## __ To return `start` and `end` as list __ +#' ## To return `start` and `end` as list +#' #' start <- hms::parse_hm("22:15") #' end <- hms::parse_hm("00:01") #' assign_date(start, end, return = "list") @@ -134,7 +138,8 @@ #' #> $end # Expected #' #> [1] "1970-01-02 00:01:00 UTC" # Expected #' -#' ## __ To return only `start` or `end` __ +#' ## To return only `start` or `end` +#' #' start <- lubridate::parse_date_time("01:10:00", "HMS") #' end <- lubridate::parse_date_time("11:45:00", "HMS") #' assign_date(start, end, return = "start") @@ -142,7 +147,8 @@ #' assign_date(start, end, return = "end") #' #> [1] "1970-01-01 11:45:00 UTC" # Expected #' -#' ## __ To assign a 24 hours interval to ambiguities __ +#' ## To assign a 24 hours interval to ambiguities +#' #' start <- lubridate::as_datetime("1985-01-15 12:00:00") #' end <- lubridate::as_datetime("2020-09-10 12:00:00") #' assign_date(start, end, ambiguity = 24) diff --git a/R/convert.R b/R/convert.R index 1de165b..68b7d6c 100644 --- a/R/convert.R +++ b/R/convert.R @@ -175,7 +175,8 @@ #' @export #' #' @examples -#' ## __ Converting from date/time objects to units __ +#' ## Converting from date/time objects to units +#' #' convert(lubridate::dhours(), "numeric", output_unit = "M") #' #> [1] 60 # Expected #' convert(lubridate::days(), "numeric", output_unit = "rad") @@ -189,7 +190,8 @@ #' convert(hms::parse_hm("15:45:00"), "numeric", output_unit = "H") #' #> [1] 15.75 # Expected #' -#' ## __ Converting from units to date/time objects __ +#' ## Converting from units to date/time objects +#' #' convert(360, "Period", input_unit = "deg") #' #> [1] "1d 0H 0M 0S" # Expected #' convert(6.5, "POSIXct", input_unit = "H") @@ -201,7 +203,8 @@ #' convert(1.308997, "Duration", input_unit = "rad") #' #> [1] "18000s (~5 hours)" # Expected #' -#' ## __ Converting between date/time objects __ +#' ## Converting between date/time objects +#' #' convert(lubridate::dseconds(120), "hms") #' #> 00:02:00 # Expected #' convert(hms::as_hms("13:45:05"), "POSIXct") @@ -214,7 +217,8 @@ #' convert(x, "POSIXct", tz = "UTC") #' #> [1] "2020-01-01 12:31:05 UTC" # Expected #' -#' ## __ Converting between units __ +#' ## Converting between units +#' #' convert(1.308997, "numeric", input_unit = "rad", output_unit = "H") #' #> [1] 5 # Expected #' convert(60, "numeric", input_unit = "deg", output_unit = "rad") @@ -226,7 +230,8 @@ #' convert(40, "numeric", input_unit = "d", output_unit = "deg") #' #> [1] 14400 # Expected #' -#' ## __ Converting from 'character' or 'numeric' to date/time objects __ +#' ## Converting from 'character' or 'numeric' to date/time objects +#' #' convert("19:55:17", "Duration", orders = "HMS") #' #> [1] "71717s (~19.92 hours)" # Expected #' convert("21:00", "Period", orders = "HM") @@ -244,7 +249,8 @@ #' convert("03/07/1982 13:00", "POSIXlt", orders = "dmy HM") #' #> [1] "1982-07-03 13:00:00 UTC" # Expected #' -#' ## __ Converting from 'character' or 'numeric' objects to units __ +#' ## Converting from 'character' or 'numeric' objects to units +#' #' convert("0145", "numeric", orders = "HM", output_unit = "M") #' #> [1] 105 # Expected #' convert(45, "numeric", orders = "M", output_unit = "H") @@ -256,7 +262,8 @@ #' convert("01:00", "numeric", orders = "HM", output_unit = "rad") #' #> [1] 0.261799 # Expected #' -#' ## __ Converting columns of a data frame __ +#' ## Converting columns of a data frame +#' #' data <- data.frame(a = 1, b = 2) #' data #' diff --git a/R/fd.R b/R/fd.R index da12828..0a05458 100644 --- a/R/fd.R +++ b/R/fd.R @@ -33,7 +33,8 @@ #' @export #' #' @examples -#' ## __ Scalar example __ +#' ## Scalar example +#' #' fd(5) #' #> [1] 2 # Expected #' fd(4) @@ -41,7 +42,8 @@ #' fd(as.numeric(NA)) #' #> [1] NA # Expected #' -#' ## __ Vector example __ +#' ## Vector example +#' #' fd(0:7) #' #> [1] 7 6 5 4 3 2 1 0 # Expected #' fd(c(1, NA)) diff --git a/R/gu.R b/R/gu.R index 1d06f45..4c858d3 100644 --- a/R/gu.R +++ b/R/gu.R @@ -71,7 +71,8 @@ #' @export #' #' @examples -#' ## __ Scalar example __ +#' ## Scalar example +#' #' gu(hms::parse_hm("08:00"), lubridate::dminutes(10)) #' #> 08:10:00 # Expected #' gu(hms::parse_hm("11:45"), lubridate::dminutes(90)) @@ -79,7 +80,8 @@ #' gu(hms::as_hms(NA), lubridate::dminutes(90)) #' #> NA # Expected #' -#' ## __ Vector example __ +#' ## Vector example +#' #' se <- c(hms::parse_hm("12:30"), hms::parse_hm("23:45")) #' si <- c(lubridate::dminutes(10), lubridate::dminutes(70)) #' gu(se, si) diff --git a/R/le_week.R b/R/le_week.R index 3fce0ae..8b76a0c 100644 --- a/R/le_week.R +++ b/R/le_week.R @@ -56,7 +56,8 @@ #' @export #' #' @examples -#' ## __ Scalar example __ +#' ## Scalar example +#' #' le_w <- lubridate::dhours(1.5) #' le_f <- lubridate::dhours(3.7) #' wd <- 5 @@ -75,7 +76,8 @@ #' le_week(le_w, le_f, wd) #' #> [1] NA # Expected #' -#' ## __ Vector example __ +#' ## Vector example +#' #' le_w <- c(lubridate::dhours(3), lubridate::dhours(2.45)) #' le_f <- c(lubridate::dhours(3), lubridate::dhours(3.75)) #' wd <- c(4, 5) @@ -83,7 +85,8 @@ #' #> [1] "10800s (~3 hours)" # Expected #' #> [2] "10157.1428571429s (~2.82 hours)" # Expected #' -#' ## __ Checking second output from vector example __ +#' ## Checking second output from vector example +#' #' if (requireNamespace("stats", quietly = TRUE)) { #' i <- 2 #' x <- c(le_w[i], le_f[i]) @@ -92,7 +95,8 @@ #' } #' #> [1] "10157.1428571429s (~2.82 hours)" # Expected #' -#' ## __ Converting the output to `hms` __ +#' ## Converting the output to `hms` +#' #' le_w <- lubridate::dhours(1.25) #' le_f <- lubridate::dhours(6.23) #' wd <- 3 @@ -102,7 +106,8 @@ #' convert(x, "hms") #' #> 04:05:44.571429 # Expected #' -#' ## __ Rounding the output at the seconds level __ +#' ## Rounding the output at the seconds level +#' #' le_w <- lubridate::dhours(3.4094) #' le_f <- lubridate::dhours(6.2345) #' wd <- 2 diff --git a/R/mctq-package.R b/R/mctq-package.R index d360cb5..eb07ad4 100644 --- a/R/mctq-package.R +++ b/R/mctq-package.R @@ -4,7 +4,7 @@ # The following block is used by usethis to automatically manage # roxygen namespace tags. Modify with care! ## usethis namespace: start -#' @importFrom dplyr across +#' @importFrom dplyr across %>% #' @importFrom lifecycle deprecate_soft #' @importFrom lubridate duration period %within% #' @importFrom hms hms diff --git a/R/ms.R b/R/ms.R index 492aff8..9d068c7 100644 --- a/R/ms.R +++ b/R/ms.R @@ -68,7 +68,8 @@ #' @export #' #' @examples -#' ## __ Scalar example __ +#' ## Scalar example +#' #' so <- hms::parse_hm("23:30") #' sd <- lubridate::dhours(8) #' ms(so, sd) @@ -84,7 +85,8 @@ #' ms(so, sd) #' #> NA # Expected #' -#' ## __ Vector example __ +#' ## Vector example +#' #' so <- c(hms::parse_hm("00:10"), hms::parse_hm("01:15")) #' sd <- c(lubridate::dhours(9.25), lubridate::dhours(5.45)) #' ms(so, sd) @@ -218,7 +220,8 @@ ms <- function(so, sd) { #' @export #' #' @examples -#' ## __ Scalar example __ +#' ## Scalar example +#' #' msf <- hms::parse_hms("04:00:00") #' sd_w <- lubridate::dhours(6) #' sd_f <- lubridate::dhours(7) @@ -243,7 +246,8 @@ ms <- function(so, sd) { #' msf_sc(msf, sd_w, sd_f, sd_week, alarm_f) #' #> NA # Expected (`msf_sc` cannot be computed if `alarm_f == TRUE`) #' -#' ## __ Vector example __ +#' ## Vector example +#' #' msf <- c(hms::parse_hms("03:45:00"), hms::parse_hm("04:45:00")) #' sd_w <- c(lubridate::dhours(9), lubridate::dhours(6.45)) #' sd_f <- c(lubridate::dhours(5), lubridate::dhours(10)) @@ -253,7 +257,8 @@ ms <- function(so, sd) { #' #> 03:45:00 # Expected #' #> 04:21:00 # Expected #' -#' ## __ A wrapper for msf_sc() __ +#' ## A wrapper for msf_sc() +#' #' msf <- hms::parse_hms("07:00:00") #' sd_w <- lubridate::dhours(6) #' sd_f <- lubridate::dhours(12) @@ -262,7 +267,8 @@ ms <- function(so, sd) { #' chronotype(msf, sd_w, sd_f, sd_week, alarm_f) #' #> 05:43:30 # Expected #' -#' ## __ Rounding the output at the seconds level __ +#' ## Rounding the output at the seconds level +#' #' msf <- hms::parse_hms("05:40:00") #' sd_w <- lubridate::dhours(5.43678) #' sd_f <- lubridate::dhours(9.345111) @@ -297,6 +303,4 @@ msf_sc <- function(msf, sd_w, sd_f, sd_week, alarm_f) { #' @rdname msf_sc #' @export -chronotype <- function(msf, sd_w, sd_f, sd_week, alarm_f) { - msf_sc(msf, sd_w, sd_f, sd_week, alarm_f) -} +chronotype <- msf_sc diff --git a/R/pretty_mctq.R b/R/pretty_mctq.R index dadff44..fad703b 100644 --- a/R/pretty_mctq.R +++ b/R/pretty_mctq.R @@ -44,10 +44,12 @@ #' c = lubridate::period(1.12345), #' d = hms::hms(1.12345)) #' -#' ## __ Rounding time objects from `data` __ +#' ## Rounding time objects from `data` +#' #' pretty_mctq(data, round = TRUE, hms = FALSE) #' -#' ## __ Converting non-`hms` time objects from `data` to `hms` __ +#' ## Converting non-`hms` time objects from `data` to `hms` +#' #' pretty_mctq(data, round = FALSE, hms = TRUE) pretty_mctq <- function(data, round = TRUE, hms = TRUE) { checkmate::assert_data_frame(data) diff --git a/R/qplot_walk.R b/R/qplot_walk.R index ce55a89..95507d7 100644 --- a/R/qplot_walk.R +++ b/R/qplot_walk.R @@ -88,19 +88,24 @@ #' #' @examples #' \dontrun{ -#' ## __ Ploting a single column from `data` __ +#' ## Ploting a single column from `data` +#' #' qplot_walk(mctq::std_mctq$bt_w) #' -#' ## __ Ploting all columns from `data` __ +#' ## Ploting all columns from `data` +#' #' qplot_walk(mctq::std_mctq, ignore = NULL, remove_id = FALSE) #' -#' ## __ Ploting selected columns from `data` __ +#' ## Ploting selected columns from `data` +#' #' qplot_walk(mctq::std_mctq, cols = c("bt_w", "msf_sc")) #' -#' ## __ Ploting selected columns from `data` using a name pattern__ +#' ## Ploting selected columns from `data` using a name pattern +#' #' qplot_walk(mctq::std_mctq, pattern = "_w$") #' -#' ## __ Examples using other datasets __ +#' ## Examples using other datasets +#' #' if (requireNamespace("datasets", quietly = TRUE)) { #' qplot_walk(datasets::iris) #' qplot_walk(datasets::mtcars) diff --git a/R/raw_data.R b/R/raw_data.R index 886bd4d..fdf18a2 100644 --- a/R/raw_data.R +++ b/R/raw_data.R @@ -18,11 +18,14 @@ #' #' @examples #' \dontrun{ -#' ## __ To list all raw dataset file names available __ +#' ## To list all raw dataset file names available +#' #' raw_data() #' -#' ## __ To get the file path from a specific raw dataset __ +#' ## To get the file path from a specific raw dataset +#' #' raw_data(raw_data()[1]) +#' #' raw_data("std_mctq.csv")} raw_data <- function(file = NULL) { checkmate::assert_string(file, null.ok = TRUE) diff --git a/R/round_time.R b/R/round_time.R index 4993c4f..f5d795e 100644 --- a/R/round_time.R +++ b/R/round_time.R @@ -27,7 +27,8 @@ #' @export #' #' @examples -#' ## __ Scalar example __ +#' ## Scalar example +#' #' lubridate::dmilliseconds(123456789) #' #> [1] "123456.789s (~1.43 days)" # Expected #' round_time(lubridate::dmilliseconds(123456789)) @@ -57,7 +58,8 @@ #' as.numeric(round_time(lubridate::as_datetime(12345.6789, tz = "EST"))) #' #> [1] 12346 # Expected #' -#' ## __ Vector example __ +#' ## Vector example +#' #' x <- c(lubridate::dhours(5.6987), lubridate::dhours(2.6875154)) #' x #' #> [1] "20515.32s (~5.7 hours)" "9675.05544s (~2.69 hours)" # Expected diff --git a/R/sd.R b/R/sd.R index d624c9f..3b37da7 100644 --- a/R/sd.R +++ b/R/sd.R @@ -67,7 +67,8 @@ #' @export #' #' @examples -#' ## __ Scalar example __ +#' ## Scalar example +#' #' so <- hms::parse_hm("23:00") #' se <- hms::parse_hm("08:00") #' sd(so, se) @@ -83,7 +84,8 @@ #' sd(so, se) #' #> [1] NA # Expected #' -#' ## __ Vector example __ +#' ## Vector example +#' #' so <- c(hms::parse_hm("04:12"), hms::parse_hm("21:20")) #' se <- c(hms::parse_hm("14:30"), hms::parse_hm("03:45")) #' sd(so, se) @@ -151,7 +153,8 @@ sd <- function(so, se) { #' @export #' #' @examples -#' ## __ Scalar example __ +#' ## Scalar example +#' #' napo <- hms::parse_hm("12:30") #' nape <- hms::parse_hm("14:20") #' napd(napo, nape) @@ -167,7 +170,8 @@ sd <- function(so, se) { #' napd(napo, nape) #' #> [1] NA # Expected #' -#' ## __ Vector example __ +#' ## Vector example +#' #' napo <- c(hms::parse_hm("01:25"), hms::parse_hm("23:50")) #' nape <- c(hms::parse_hm("03:10"), hms::parse_hm("01:10")) #' napd(napo, nape) @@ -245,7 +249,8 @@ napd <- function(napo, nape) { #' @export #' #' @examples -#' ## __ Scalar example __ +#' ## Scalar example +#' #' sd <- lubridate::dhours(6) #' napd <- lubridate::dhours(0.5) #' nap <- TRUE @@ -270,7 +275,8 @@ napd <- function(napo, nape) { #' sd24(sd, napd, nap) #' #> [1] NA # Expected #' -#' ## __ Vector example __ +#' ## Vector example +#' #' sd <- c(lubridate::dhours(7.5), lubridate::dhours(8)) #' napd <- c(lubridate::dhours(0.75), lubridate::dhours(1)) #' nap <- c(TRUE, TRUE) @@ -353,7 +359,8 @@ sd24 <- function(sd, napd, nap) { #' @export #' #' @examples -#' ## __ Scalar example __ +#' ## Scalar example +#' #' sd_w <- lubridate::dhours(4) #' sd_f <- lubridate::dhours(8) #' wd <- 5 @@ -372,14 +379,16 @@ sd24 <- function(sd, napd, nap) { #' sd_week(sd_w, sd_f, wd) #' #> [1] NA # Expected #' -#' ## __ Vector example __ +#' ## Vector example +#' #' sd_w <- c(lubridate::dhours(4.5), lubridate::dhours(5.45)) #' sd_f <- c(lubridate::dhours(8), lubridate::dhours(7.3)) #' wd <- c(3, 7) #' sd_week(sd_w, sd_f, wd) #' #> [1] "23400s (~6.5 hours)" "19620s (~5.45 hours)" # Expected #' -#' ## __ Checking second output from vector example __ +#' ## Checking second output from vector example +#' #' if (requireNamespace("stats", quietly = TRUE)) { #' i <- 2 #' x <- c(sd_w[i], sd_f[i]) @@ -388,7 +397,8 @@ sd24 <- function(sd, napd, nap) { #' } #' #> [1] "19620s (~5.45 hours)" # Expected #' -#' ## __ Converting the output to hms __ +#' ## Converting the output to hms +#' #' sd_w <- lubridate::dhours(5.45) #' sd_f <- lubridate::dhours(9.5) #' wd <- 5 @@ -398,7 +408,8 @@ sd24 <- function(sd, napd, nap) { #' convert(x, "hms") #' #> 06:36:25.714286 # Expected #' -#' ## __ Rounding the output at the seconds level __ +#' ## Rounding the output at the seconds level +#' #' sd_w <- lubridate::dhours(4.5) #' sd_f <- lubridate::dhours(7.8) #' wd <- 3 @@ -497,7 +508,8 @@ sd_week <- function(sd_w, sd_f, wd) { #' @export #' #' @examples -#' ## __ Scalar example __ +#' ## Scalar example +#' #' sd_w <- lubridate::dhours(5) #' sd_f <- lubridate::dhours(9) #' n_w <- 2 @@ -519,7 +531,8 @@ sd_week <- function(sd_w, sd_f, wd) { #' sd_overall(sd_w, sd_f, n_w, n_f) #' #> [1] NA # Expected #' -#' ## __ Vector example __ +#' ## Vector example +#' #' sd_w <- c(lubridate::dhours(4), lubridate::dhours(7)) #' sd_f <- c(lubridate::dhours(12), lubridate::dhours(9)) #' n_w <- c(3, 4) @@ -527,7 +540,8 @@ sd_week <- function(sd_w, sd_f, wd) { #' sd_overall(sd_w, sd_f, n_w, n_f) #' #> [1] "25920s (~7.2 hours)" "28800s (~8 hours)" # Expected #' -#' ## __ Checking second output from vector example __ +#' ## Checking second output from vector example +#' #' if (requireNamespace("stats", quietly = TRUE)) { #' i <- 2 #' x <- c(sd_w[i], sd_f[i]) @@ -536,7 +550,8 @@ sd_week <- function(sd_w, sd_f, wd) { #' } #' #> [1] "28800s (~8 hours)" # Expected #' -#' ## __ Converting the output to hms __ +#' ## Converting the output to hms +#' #' sd_w <- lubridate::dhours(4.75) #' sd_f <- lubridate::dhours(10) #' n_w <- 5 @@ -547,7 +562,8 @@ sd_week <- function(sd_w, sd_f, wd) { #' convert(x, "hms") #' #> 06:15:00 # Expected #' -#' ## __ Rounding the output at the seconds level __ +#' ## Rounding the output at the seconds level +#' #' sd_w <- lubridate::dhours(5.9874) #' sd_f <- lubridate::dhours(9.3) #' n_w <- 3 diff --git a/R/shortest_interval.R b/R/shortest_interval.R index 9dbe77b..be7cce7 100644 --- a/R/shortest_interval.R +++ b/R/shortest_interval.R @@ -105,7 +105,8 @@ #' @export #' #' @examples -#' ## __ Scalar example __ +#' ## Scalar example +#' #' x <- hms::parse_hm("23:00") #' y <- hms::parse_hm("01:00") #' shortest_interval(x, y) @@ -116,14 +117,16 @@ #' shortest_interval(x, y) #' #> 00:00:00 # Expected #' -#' ## __ Vector example __ +#' ## Vector example +#' #' x <- c(hms::parse_hm("15:30"), hms::parse_hm("21:30")) #' y <- c(hms::parse_hm("19:30"), hms::parse_hm("04:00")) #' shortest_interval(x, y) #' #> 04:00:00 # Expected #' #> 06:30:00 # Expected #' -#' ## __ Finding the longer interval between two hours __ +#' ## Finding the longer interval between two hours +#' #' x <- lubridate::parse_date_time("01:10:00", "HMS") #' y <- lubridate::parse_date_time("11:45:00", "HMS") #' shortest_interval(x, y, inverse = TRUE) @@ -134,7 +137,8 @@ #' longer_interval(x, y) #' #> 24:00:00 # Expected #' -#' ## __ Changing the output object class __ +#' ## Changing the output object class +#' #' x <- as.POSIXct("1988-10-05 02:00:00") #' y <- as.POSIXlt("2100-05-07 13:30:00") #' shortest_interval(x, y, "Interval") diff --git a/R/sjl.R b/R/sjl.R index f4f6502..b3ba6d7 100644 --- a/R/sjl.R +++ b/R/sjl.R @@ -132,7 +132,8 @@ #' @export #' #' @examples -#' ## __ Scalar example __ +#' ## Scalar example +#' #' msw <- hms::parse_hm("03:30") #' msf <- hms::parse_hm("05:00") #' sjl(msw, msf) @@ -156,7 +157,8 @@ #' sjl(msw, msf) #' #> [1] NA # Expected #' -#' ## __ Vector example __ +#' ## Vector example +#' #' msw <- c(hms::parse_hm("02:05"), hms::parse_hm("04:05")) #' msf <- c(hms::parse_hm("23:05"), hms::parse_hm("04:05")) #' sjl(msw, msf) @@ -166,7 +168,8 @@ #' sjl_rel(msw, msf) # Wrapper function #' #> [1] "-10800s (~-3 hours)" "0s" # Expected #' -#' ## __ Using different methods __ +#' ## Using different methods +#' #' msw <- hms::parse_hm("19:15") #' msf <- hms::parse_hm("02:30") #' sjl(msw, msf, abs = FALSE, method = "difference") @@ -185,7 +188,7 @@ #' sjl(msw, msf, abs = FALSE, method = "longer") #' #> [1] "-81000s (~-22.5 hours)" # Expected #' -#' ## __ Converting the output to `hms` __ +#' ## Converting the output to `hms` #' msw <- hms::parse_hm("01:15") #' msf <- hms::parse_hm("03:25") #' x <- sjl(msw, msf) @@ -194,7 +197,7 @@ #' convert(x, "hms") #' #> 02:10:00 # Expected #' -#' ## __ Rounding the output at the seconds level __ +#' ## Rounding the output at the seconds level #' msw <- hms::parse_hms("04:19:33.1234") #' msf <- hms::parse_hms("02:55:05") #' x <- sjl(msw, msf) @@ -321,7 +324,8 @@ sjl_rel <- function(msw, msf, method = "shortest") { #' @export #' #' @examples -#' ## __ Scalar example __ +#' ## Scalar example +#' #' sjl <- list(sjl_m = lubridate::dhours(1.25), #' sjl_e = lubridate::dhours(0.5), #' sjl_n = lubridate::dhours(3)) @@ -336,7 +340,8 @@ sjl_rel <- function(msw, msf, method = "shortest") { #' sjl_weighted(sjl, n_w) #' #> [1] NA # Expected #' -#' ## __ Vector example __ +#' ## Vector example +#' #' sjl <- list(sjl_m = c(lubridate::dhours(2), lubridate::dhours(2.45)), #' sjl_e = c(lubridate::dhours(3.21), lubridate::as.duration(NA)), #' sjl_n = c(lubridate::dhours(1.2), lubridate::dhours(5.32))) @@ -344,7 +349,8 @@ sjl_rel <- function(msw, msf, method = "shortest") { #' sjl_weighted(sjl, n_w) #' #> [1] "8298s (~2.31 hours)" NA # Expected #' -#' ## __ Checking the first output from vector example __ +#' ## Checking the first output from vector example +#' #' if (requireNamespace("stats", quietly = TRUE)) { #' i <- 1 #' x <- c(sjl[["sjl_m"]][i], sjl[["sjl_e"]][i], sjl[["sjl_n"]][i]) @@ -353,7 +359,8 @@ sjl_rel <- function(msw, msf, method = "shortest") { #' } #' #> [1] "8298s (~2.31 hours)" # Expected #' -#' ## __ Converting the output to hms __ +#' ## Converting the output to hms +#' #' sjl <- list(sjl_m = lubridate::dhours(0.25), #' sjl_e = lubridate::dhours(1.2), #' sjl_n = lubridate::dhours(4.32)) @@ -363,7 +370,8 @@ sjl_rel <- function(msw, msf, method = "shortest") { #' convert(sjl_weighted(sjl, n_w), "hms") #' #> 01:06:10.285714 # Expected #' -#' ## __ Rounding the output at the seconds level __ +#' ## Rounding the output at the seconds level +#' #' round_time(sjl_weighted(sjl, n_w)) #' #> [1] "3970s (~1.1 hours)" # Expected #' round_time(convert(sjl_weighted(sjl, n_w), "hms")) diff --git a/R/sloss_week.R b/R/sloss_week.R index 1abc954..e5acb5a 100644 --- a/R/sloss_week.R +++ b/R/sloss_week.R @@ -47,7 +47,8 @@ #' @export #' #' @examples -#' ## __ Scalar example __ +#' ## Scalar example +#' #' sd_w <- lubridate::dhours(6.5) #' sd_f <- lubridate::dhours(7) #' wd <- 4 @@ -66,14 +67,16 @@ #' sloss_week(sd_w, sd_f, wd) #' #> [1] NA # Expected #' -#' ## __ Vector example __ +#' ## Vector example +#' #' sd_w <- c(lubridate::dhours(7), lubridate::dhours(8)) #' sd_f <- c(lubridate::dhours(6.5), lubridate::dhours(8)) #' wd <- c(2, 0) #' sloss_week(sd_w, sd_f, wd) #' #> [1] "2571.42857142857s (~42.86 minutes)" "0s" # Expected #' -#' ## __ Converting the output to `hms` __ +#' ## Converting the output to `hms` +#' #' sd_w <- lubridate::dhours(4) #' sd_f <- lubridate::dhours(5) #' wd <- 3 @@ -83,7 +86,8 @@ #' convert(x, "hms") #' #> 01:42:51.428571 # Expected #' -#' ## __ Rounding the output at the seconds level __ +#' ## Rounding the output at the seconds level +#' #' sd_w <- lubridate::dhours(5.8743) #' sd_f <- lubridate::dhours(7.4324) #' wd <- 6 diff --git a/R/so.R b/R/so.R index f46d721..26b3d4f 100644 --- a/R/so.R +++ b/R/so.R @@ -75,7 +75,8 @@ #' @export #' #' @examples -#' ## __ Scalar example __ +#' ## Scalar example +#' #' sprep <- hms::parse_hm("22:00") #' slat <- lubridate::dminutes(15) #' so(sprep, slat) @@ -91,7 +92,8 @@ #' so(sprep, slat) #' #> NA # Expected #' -#' ## __ Vector example __ +#' ## Vector example +#' #' sprep <- c(hms::parse_hm("21:30"), hms::parse_hm("22:15")) #' slat <- c(lubridate::dminutes(45), lubridate::dminutes(5)) #' so(sprep, slat) diff --git a/R/sum_time.R b/R/sum_time.R index e0f4ab7..23ae952 100644 --- a/R/sum_time.R +++ b/R/sum_time.R @@ -85,13 +85,15 @@ #' @export #' #' @examples -#' ## __ Linear non-vectorized sum __ +#' ## Linear non-vectorized sum +#' #' x <- c(as.POSIXct("2020-01-01 15:00:00"), as.POSIXct("1999-05-04 17:30:00")) #' y <- lubridate::as.interval(lubridate::dhours(7), as.Date("1970-05-08")) #' sum_time(x, y, class = "duration") #' #> [1] "142200s (~1.65 days)" # Expected #' -#' ## __ Non-vectorized sum in a circular time frame of 24 hours __ +#' ## Non-vectorized sum in a circular time frame of 24 hours +#' #' x <- c(lubridate::hours(25), lubridate::dhours(5), lubridate::minutes(50)) #' sum_time(x, circular = TRUE) #' #> 06:50:00 # Expected @@ -102,7 +104,8 @@ #' sum_time(x, circular = TRUE, na.rm = TRUE) #' #> 02:45:00 # Expected #' -#' ## __ Linear vectorized sum __ +#' ## Linear vectorized sum +#' #' x <- c(lubridate::dhours(6), NA) #' y <- c(hms::parse_hm("23:00"), hms::parse_hm("10:00")) #' sum_time(x, y, vectorize = TRUE) @@ -112,7 +115,8 @@ #' #> 29:00:00 # Expected #' #> 10:00:00 # Expected #' -#' ## __ Vectorized sum in a circular time frame of 24 hours __ +#' ## Vectorized sum in a circular time frame of 24 hours +#' #' x <- c(lubridate::dhours(6), NA) #' y <- c(hms::parse_hm("23:00"), hms::parse_hm("10:00")) #' sum_time(x, y, circular = TRUE, vectorize = TRUE) diff --git a/R/tbt.R b/R/tbt.R index 537b314..a2f32bd 100644 --- a/R/tbt.R +++ b/R/tbt.R @@ -68,7 +68,8 @@ #' @export #' #' @examples -#' ## __ Scalar example __ +#' ## Scalar example +#' #' bt <- hms::parse_hm("22:10") #' gu <- hms::parse_hm("06:15") #' tbt(bt, gu) @@ -84,7 +85,8 @@ #' tbt(bt, gu) #' #> [1] NA # Expected #' -#' ## __ Vector example __ +#' ## Vector example +#' #' bt <- c(hms::parse_hm("23:50"), hms::parse_hm("02:30")) #' gu <- c(hms::parse_hm("09:30"), hms::parse_hm("11:25")) #' tbt(bt, gu) diff --git a/man/assign_date.Rd b/man/assign_date.Rd index f58686e..ec92e52 100644 --- a/man/assign_date.Rd +++ b/man/assign_date.Rd @@ -113,7 +113,8 @@ their dates. Only the time will be considered. } } \examples{ -## __ Scalar example __ +## Scalar example + start <- hms::parse_hms("23:11:00") end <- hms::parse_hms("05:30:00") assign_date(start, end) @@ -129,20 +130,23 @@ end <- hms::as_hms(NA) assign_date(start, end) #> [1] NA--NA # Expected -## __ Vector example __ +## Vector example + start <- c(hms::parse_hm("09:45"), hms::parse_hm("20:30")) end <- c(hms::parse_hm("21:15"), hms::parse_hm("04:30")) assign_date(start, end) #> [1] 1970-01-01 09:45:00 UTC--1970-01-01 21:15:00 UTC # Expected #> [2] 1970-01-01 20:30:00 UTC--1970-01-02 04:30:00 UTC # Expected -## __ To return `start` and `end` as interval (default)__ +## To return `start` and `end` as interval (default) + start <- hms::parse_hm("12:34") end <- hms::parse_hm("01:25") assign_date(start, end) #> [1] 1970-01-01 12:34:00 UTC--1970-01-02 01:25:00 UTC # Expected -## __ To return `start` and `end` as list __ +## To return `start` and `end` as list + start <- hms::parse_hm("22:15") end <- hms::parse_hm("00:01") assign_date(start, end, return = "list") @@ -152,7 +156,8 @@ assign_date(start, end, return = "list") #> $end # Expected #> [1] "1970-01-02 00:01:00 UTC" # Expected -## __ To return only `start` or `end` __ +## To return only `start` or `end` + start <- lubridate::parse_date_time("01:10:00", "HMS") end <- lubridate::parse_date_time("11:45:00", "HMS") assign_date(start, end, return = "start") @@ -160,7 +165,8 @@ assign_date(start, end, return = "start") assign_date(start, end, return = "end") #> [1] "1970-01-01 11:45:00 UTC" # Expected -## __ To assign a 24 hours interval to ambiguities __ +## To assign a 24 hours interval to ambiguities + start <- lubridate::as_datetime("1985-01-15 12:00:00") end <- lubridate::as_datetime("2020-09-10 12:00:00") assign_date(start, end, ambiguity = 24) diff --git a/man/convert.Rd b/man/convert.Rd index d0e64da..47a67fc 100644 --- a/man/convert.Rd +++ b/man/convert.Rd @@ -345,7 +345,8 @@ seconds equivalent to the unit duration. You can also assign a lubridate } } \examples{ -## __ Converting from date/time objects to units __ +## Converting from date/time objects to units + convert(lubridate::dhours(), "numeric", output_unit = "M") #> [1] 60 # Expected convert(lubridate::days(), "numeric", output_unit = "rad") @@ -359,7 +360,8 @@ convert(x, "numeric", output_unit = "d", ignore_date = FALSE) convert(hms::parse_hm("15:45:00"), "numeric", output_unit = "H") #> [1] 15.75 # Expected -## __ Converting from units to date/time objects __ +## Converting from units to date/time objects + convert(360, "Period", input_unit = "deg") #> [1] "1d 0H 0M 0S" # Expected convert(6.5, "POSIXct", input_unit = "H") @@ -371,7 +373,8 @@ convert(1, "Posixlt", input_unit = "W") convert(1.308997, "Duration", input_unit = "rad") #> [1] "18000s (~5 hours)" # Expected -## __ Converting between date/time objects __ +## Converting between date/time objects + convert(lubridate::dseconds(120), "hms") #> 00:02:00 # Expected convert(hms::as_hms("13:45:05"), "POSIXct") @@ -384,7 +387,8 @@ x <- lubridate::ymd_hms("2020-01-01 12:31:05", tz = "EST") convert(x, "POSIXct", tz = "UTC") #> [1] "2020-01-01 12:31:05 UTC" # Expected -## __ Converting between units __ +## Converting between units + convert(1.308997, "numeric", input_unit = "rad", output_unit = "H") #> [1] 5 # Expected convert(60, "numeric", input_unit = "deg", output_unit = "rad") @@ -396,7 +400,8 @@ convert(0.2617994, "numeric", input_unit = "rad", output_unit = "H") convert(40, "numeric", input_unit = "d", output_unit = "deg") #> [1] 14400 # Expected -## __ Converting from 'character' or 'numeric' to date/time objects __ +## Converting from 'character' or 'numeric' to date/time objects + convert("19:55:17", "Duration", orders = "HMS") #> [1] "71717s (~19.92 hours)" # Expected convert("21:00", "Period", orders = "HM") @@ -414,7 +419,8 @@ convert("2020-01-01 12:31:05", "POSIXct", orders = "ymd HMS", tz = "EST") convert("03/07/1982 13:00", "POSIXlt", orders = "dmy HM") #> [1] "1982-07-03 13:00:00 UTC" # Expected -## __ Converting from 'character' or 'numeric' objects to units __ +## Converting from 'character' or 'numeric' objects to units + convert("0145", "numeric", orders = "HM", output_unit = "M") #> [1] 105 # Expected convert(45, "numeric", orders = "M", output_unit = "H") @@ -426,7 +432,8 @@ convert("2020-03-15 02", "numeric", orders = "ymd H", output_unit = "H") convert("01:00", "numeric", orders = "HM", output_unit = "rad") #> [1] 0.261799 # Expected -## __ Converting columns of a data frame __ +## Converting columns of a data frame + data <- data.frame(a = 1, b = 2) data diff --git a/man/fd.Rd b/man/fd.Rd index 4791844..fce89f9 100644 --- a/man/fd.Rd +++ b/man/fd.Rd @@ -52,7 +52,8 @@ days per week"). } \examples{ -## __ Scalar example __ +## Scalar example + fd(5) #> [1] 2 # Expected fd(4) @@ -60,7 +61,8 @@ fd(4) fd(as.numeric(NA)) #> [1] NA # Expected -## __ Vector example __ +## Vector example + fd(0:7) #> [1] 7 6 5 4 3 2 1 0 # Expected fd(c(1, NA)) diff --git a/man/gu.Rd b/man/gu.Rd index 3b31b26..4a0bb1b 100644 --- a/man/gu.Rd +++ b/man/gu.Rd @@ -112,7 +112,8 @@ morning shift; \eqn{E} = evening shift; \eqn{N} = night shift. } \examples{ -## __ Scalar example __ +## Scalar example + gu(hms::parse_hm("08:00"), lubridate::dminutes(10)) #> 08:10:00 # Expected gu(hms::parse_hm("11:45"), lubridate::dminutes(90)) @@ -120,7 +121,8 @@ gu(hms::parse_hm("11:45"), lubridate::dminutes(90)) gu(hms::as_hms(NA), lubridate::dminutes(90)) #> NA # Expected -## __ Vector example __ +## Vector example + se <- c(hms::parse_hm("12:30"), hms::parse_hm("23:45")) si <- c(lubridate::dminutes(10), lubridate::dminutes(70)) gu(se, si) diff --git a/man/le_week.Rd b/man/le_week.Rd index abdff8b..afcba85 100644 --- a/man/le_week.Rd +++ b/man/le_week.Rd @@ -116,7 +116,8 @@ more. } \examples{ -## __ Scalar example __ +## Scalar example + le_w <- lubridate::dhours(1.5) le_f <- lubridate::dhours(3.7) wd <- 5 @@ -135,7 +136,8 @@ wd <- 3 le_week(le_w, le_f, wd) #> [1] NA # Expected -## __ Vector example __ +## Vector example + le_w <- c(lubridate::dhours(3), lubridate::dhours(2.45)) le_f <- c(lubridate::dhours(3), lubridate::dhours(3.75)) wd <- c(4, 5) @@ -143,7 +145,8 @@ le_week(le_w, le_f, wd) #> [1] "10800s (~3 hours)" # Expected #> [2] "10157.1428571429s (~2.82 hours)" # Expected -## __ Checking second output from vector example __ +## Checking second output from vector example + if (requireNamespace("stats", quietly = TRUE)) { i <- 2 x <- c(le_w[i], le_f[i]) @@ -152,7 +155,8 @@ if (requireNamespace("stats", quietly = TRUE)) { } #> [1] "10157.1428571429s (~2.82 hours)" # Expected -## __ Converting the output to `hms` __ +## Converting the output to `hms` + le_w <- lubridate::dhours(1.25) le_f <- lubridate::dhours(6.23) wd <- 3 @@ -162,7 +166,8 @@ x convert(x, "hms") #> 04:05:44.571429 # Expected -## __ Rounding the output at the seconds level __ +## Rounding the output at the seconds level + le_w <- lubridate::dhours(3.4094) le_f <- lubridate::dhours(6.2345) wd <- 2 diff --git a/man/mctq-package.Rd b/man/mctq-package.Rd index d9b6055..501e926 100644 --- a/man/mctq-package.Rd +++ b/man/mctq-package.Rd @@ -32,6 +32,7 @@ Authors: Other contributors: \itemize{ + \item Jonathan Keane \email{jkeane@gmail.com} (\href{https://orcid.org/0000-0001-7087-9776}{ORCID}) [reviewer] \item Interdisciplinary Sleep Research Group (GIPSO) [funder, copyright holder] \item University of Sao Paulo (USP) [funder] } diff --git a/man/ms.Rd b/man/ms.Rd index 05da43c..8bbacf9 100644 --- a/man/ms.Rd +++ b/man/ms.Rd @@ -110,7 +110,8 @@ morning shift; \eqn{E} = evening shift; \eqn{N} = night shift. } \examples{ -## __ Scalar example __ +## Scalar example + so <- hms::parse_hm("23:30") sd <- lubridate::dhours(8) ms(so, sd) @@ -126,7 +127,8 @@ sd <- lubridate::dhours(7.5) ms(so, sd) #> NA # Expected -## __ Vector example __ +## Vector example + so <- c(hms::parse_hm("00:10"), hms::parse_hm("01:15")) sd <- c(lubridate::dhours(9.25), lubridate::dhours(5.45)) ms(so, sd) diff --git a/man/msf_sc.Rd b/man/msf_sc.Rd index a98a904..01f9fe4 100644 --- a/man/msf_sc.Rd +++ b/man/msf_sc.Rd @@ -181,7 +181,8 @@ more. } \examples{ -## __ Scalar example __ +## Scalar example + msf <- hms::parse_hms("04:00:00") sd_w <- lubridate::dhours(6) sd_f <- lubridate::dhours(7) @@ -206,7 +207,8 @@ alarm_f <- TRUE msf_sc(msf, sd_w, sd_f, sd_week, alarm_f) #> NA # Expected (`msf_sc` cannot be computed if `alarm_f == TRUE`) -## __ Vector example __ +## Vector example + msf <- c(hms::parse_hms("03:45:00"), hms::parse_hm("04:45:00")) sd_w <- c(lubridate::dhours(9), lubridate::dhours(6.45)) sd_f <- c(lubridate::dhours(5), lubridate::dhours(10)) @@ -216,7 +218,8 @@ msf_sc(msf, sd_w, sd_f, sd_week, alarm_f) #> 03:45:00 # Expected #> 04:21:00 # Expected -## __ A wrapper for msf_sc() __ +## A wrapper for msf_sc() + msf <- hms::parse_hms("07:00:00") sd_w <- lubridate::dhours(6) sd_f <- lubridate::dhours(12) @@ -225,7 +228,8 @@ alarm_f <- FALSE chronotype(msf, sd_w, sd_f, sd_week, alarm_f) #> 05:43:30 # Expected -## __ Rounding the output at the seconds level __ +## Rounding the output at the seconds level + msf <- hms::parse_hms("05:40:00") sd_w <- lubridate::dhours(5.43678) sd_f <- lubridate::dhours(9.345111) diff --git a/man/napd.Rd b/man/napd.Rd index 03e6c1f..a61ce70 100644 --- a/man/napd.Rd +++ b/man/napd.Rd @@ -93,7 +93,8 @@ morning shift; \eqn{E} = evening shift; \eqn{N} = night shift. } \examples{ -## __ Scalar example __ +## Scalar example + napo <- hms::parse_hm("12:30") nape <- hms::parse_hm("14:20") napd(napo, nape) @@ -109,7 +110,8 @@ nape <- hms::as_hms(NA) napd(napo, nape) #> [1] NA # Expected -## __ Vector example __ +## Vector example + napo <- c(hms::parse_hm("01:25"), hms::parse_hm("23:50")) nape <- c(hms::parse_hm("03:10"), hms::parse_hm("01:10")) napd(napo, nape) diff --git a/man/pretty_mctq.Rd b/man/pretty_mctq.Rd index f8bd46d..5bffebf 100644 --- a/man/pretty_mctq.Rd +++ b/man/pretty_mctq.Rd @@ -50,10 +50,12 @@ data <- data.frame( c = lubridate::period(1.12345), d = hms::hms(1.12345)) -## __ Rounding time objects from `data` __ +## Rounding time objects from `data` + pretty_mctq(data, round = TRUE, hms = FALSE) -## __ Converting non-`hms` time objects from `data` to `hms` __ +## Converting non-`hms` time objects from `data` to `hms` + pretty_mctq(data, round = FALSE, hms = TRUE) } \seealso{ diff --git a/man/qplot_walk.Rd b/man/qplot_walk.Rd index 3bb504e..3e9d161 100644 --- a/man/qplot_walk.Rd +++ b/man/qplot_walk.Rd @@ -110,19 +110,24 @@ You can disable this behavior using \code{remove_id = FALSE}. } \examples{ \dontrun{ -## __ Ploting a single column from `data` __ +## Ploting a single column from `data` + qplot_walk(mctq::std_mctq$bt_w) -## __ Ploting all columns from `data` __ +## Ploting all columns from `data` + qplot_walk(mctq::std_mctq, ignore = NULL, remove_id = FALSE) -## __ Ploting selected columns from `data` __ +## Ploting selected columns from `data` + qplot_walk(mctq::std_mctq, cols = c("bt_w", "msf_sc")) -## __ Ploting selected columns from `data` using a name pattern__ +## Ploting selected columns from `data` using a name pattern + qplot_walk(mctq::std_mctq, pattern = "_w$") -## __ Examples using other datasets __ +## Examples using other datasets + if (requireNamespace("datasets", quietly = TRUE)) { qplot_walk(datasets::iris) qplot_walk(datasets::mtcars) diff --git a/man/raw_data.Rd b/man/raw_data.Rd index ee40881..02aa105 100644 --- a/man/raw_data.Rd +++ b/man/raw_data.Rd @@ -22,11 +22,14 @@ purposes. \code{raw_data()} makes it easy to access their paths. } \examples{ \dontrun{ -## __ To list all raw dataset file names available __ +## To list all raw dataset file names available + raw_data() -## __ To get the file path from a specific raw dataset __ +## To get the file path from a specific raw dataset + raw_data(raw_data()[1]) + raw_data("std_mctq.csv")} } \seealso{ diff --git a/man/round_time.Rd b/man/round_time.Rd index f888307..1676963 100644 --- a/man/round_time.Rd +++ b/man/round_time.Rd @@ -27,7 +27,8 @@ for rounding off a 5. Therefore, \code{round(0.5)} is equal to 0 and \code{round is equal to -2. See \code{?round} to learn more. } \examples{ -## __ Scalar example __ +## Scalar example + lubridate::dmilliseconds(123456789) #> [1] "123456.789s (~1.43 days)" # Expected round_time(lubridate::dmilliseconds(123456789)) @@ -57,7 +58,8 @@ round_time(lubridate::as_datetime(12345.6789, tz = "EST")) as.numeric(round_time(lubridate::as_datetime(12345.6789, tz = "EST"))) #> [1] 12346 # Expected -## __ Vector example __ +## Vector example + x <- c(lubridate::dhours(5.6987), lubridate::dhours(2.6875154)) x #> [1] "20515.32s (~5.7 hours)" "9675.05544s (~2.69 hours)" # Expected diff --git a/man/sd.Rd b/man/sd.Rd index ff577a6..40ca5eb 100644 --- a/man/sd.Rd +++ b/man/sd.Rd @@ -109,7 +109,8 @@ morning shift; \eqn{E} = evening shift; \eqn{N} = night shift. } \examples{ -## __ Scalar example __ +## Scalar example + so <- hms::parse_hm("23:00") se <- hms::parse_hm("08:00") sd(so, se) @@ -125,7 +126,8 @@ se <- hms::as_hms(NA) sd(so, se) #> [1] NA # Expected -## __ Vector example __ +## Vector example + so <- c(hms::parse_hm("04:12"), hms::parse_hm("21:20")) se <- c(hms::parse_hm("14:30"), hms::parse_hm("03:45")) sd(so, se) diff --git a/man/sd24.Rd b/man/sd24.Rd index 9483a38..ea567f1 100644 --- a/man/sd24.Rd +++ b/man/sd24.Rd @@ -102,7 +102,8 @@ morning shift; \eqn{E} = evening shift; \eqn{N} = night shift. } \examples{ -## __ Scalar example __ +## Scalar example + sd <- lubridate::dhours(6) napd <- lubridate::dhours(0.5) nap <- TRUE @@ -127,7 +128,8 @@ nap <- TRUE sd24(sd, napd, nap) #> [1] NA # Expected -## __ Vector example __ +## Vector example + sd <- c(lubridate::dhours(7.5), lubridate::dhours(8)) napd <- c(lubridate::dhours(0.75), lubridate::dhours(1)) nap <- c(TRUE, TRUE) diff --git a/man/sd_overall.Rd b/man/sd_overall.Rd index 42c1030..26502e4 100644 --- a/man/sd_overall.Rd +++ b/man/sd_overall.Rd @@ -117,7 +117,8 @@ morning shift; \eqn{E} = evening shift; \eqn{N} = night shift. } \examples{ -## __ Scalar example __ +## Scalar example + sd_w <- lubridate::dhours(5) sd_f <- lubridate::dhours(9) n_w <- 2 @@ -139,7 +140,8 @@ n_f <- 4 sd_overall(sd_w, sd_f, n_w, n_f) #> [1] NA # Expected -## __ Vector example __ +## Vector example + sd_w <- c(lubridate::dhours(4), lubridate::dhours(7)) sd_f <- c(lubridate::dhours(12), lubridate::dhours(9)) n_w <- c(3, 4) @@ -147,7 +149,8 @@ n_f <- c(2, 4) sd_overall(sd_w, sd_f, n_w, n_f) #> [1] "25920s (~7.2 hours)" "28800s (~8 hours)" # Expected -## __ Checking second output from vector example __ +## Checking second output from vector example + if (requireNamespace("stats", quietly = TRUE)) { i <- 2 x <- c(sd_w[i], sd_f[i]) @@ -156,7 +159,8 @@ if (requireNamespace("stats", quietly = TRUE)) { } #> [1] "28800s (~8 hours)" # Expected -## __ Converting the output to hms __ +## Converting the output to hms + sd_w <- lubridate::dhours(4.75) sd_f <- lubridate::dhours(10) n_w <- 5 @@ -167,7 +171,8 @@ x convert(x, "hms") #> 06:15:00 # Expected -## __ Rounding the output at the seconds level __ +## Rounding the output at the seconds level + sd_w <- lubridate::dhours(5.9874) sd_f <- lubridate::dhours(9.3) n_w <- 3 diff --git a/man/sd_week.Rd b/man/sd_week.Rd index d3807a3..cc9902e 100644 --- a/man/sd_week.Rd +++ b/man/sd_week.Rd @@ -121,7 +121,8 @@ more. } \examples{ -## __ Scalar example __ +## Scalar example + sd_w <- lubridate::dhours(4) sd_f <- lubridate::dhours(8) wd <- 5 @@ -140,14 +141,16 @@ wd <- 6 sd_week(sd_w, sd_f, wd) #> [1] NA # Expected -## __ Vector example __ +## Vector example + sd_w <- c(lubridate::dhours(4.5), lubridate::dhours(5.45)) sd_f <- c(lubridate::dhours(8), lubridate::dhours(7.3)) wd <- c(3, 7) sd_week(sd_w, sd_f, wd) #> [1] "23400s (~6.5 hours)" "19620s (~5.45 hours)" # Expected -## __ Checking second output from vector example __ +## Checking second output from vector example + if (requireNamespace("stats", quietly = TRUE)) { i <- 2 x <- c(sd_w[i], sd_f[i]) @@ -156,7 +159,8 @@ if (requireNamespace("stats", quietly = TRUE)) { } #> [1] "19620s (~5.45 hours)" # Expected -## __ Converting the output to hms __ +## Converting the output to hms + sd_w <- lubridate::dhours(5.45) sd_f <- lubridate::dhours(9.5) wd <- 5 @@ -166,7 +170,8 @@ x convert(x, "hms") #> 06:36:25.714286 # Expected -## __ Rounding the output at the seconds level __ +## Rounding the output at the seconds level + sd_w <- lubridate::dhours(4.5) sd_f <- lubridate::dhours(7.8) wd <- 3 diff --git a/man/shortest_interval.Rd b/man/shortest_interval.Rd index 2c1ac29..e995f84 100644 --- a/man/shortest_interval.Rd +++ b/man/shortest_interval.Rd @@ -115,7 +115,8 @@ dates. Only the time will be considered. } } \examples{ -## __ Scalar example __ +## Scalar example + x <- hms::parse_hm("23:00") y <- hms::parse_hm("01:00") shortest_interval(x, y) @@ -126,14 +127,16 @@ y <- lubridate::as_datetime("2020-09-10 12:00:00") shortest_interval(x, y) #> 00:00:00 # Expected -## __ Vector example __ +## Vector example + x <- c(hms::parse_hm("15:30"), hms::parse_hm("21:30")) y <- c(hms::parse_hm("19:30"), hms::parse_hm("04:00")) shortest_interval(x, y) #> 04:00:00 # Expected #> 06:30:00 # Expected -## __ Finding the longer interval between two hours __ +## Finding the longer interval between two hours + x <- lubridate::parse_date_time("01:10:00", "HMS") y <- lubridate::parse_date_time("11:45:00", "HMS") shortest_interval(x, y, inverse = TRUE) @@ -144,7 +147,8 @@ y <- lubridate::as_datetime("1970-07-01 05:00:00") longer_interval(x, y) #> 24:00:00 # Expected -## __ Changing the output object class __ +## Changing the output object class + x <- as.POSIXct("1988-10-05 02:00:00") y <- as.POSIXlt("2100-05-07 13:30:00") shortest_interval(x, y, "Interval") diff --git a/man/sjl.Rd b/man/sjl.Rd index f946e43..8929140 100644 --- a/man/sjl.Rd +++ b/man/sjl.Rd @@ -204,7 +204,8 @@ more. } \examples{ -## __ Scalar example __ +## Scalar example + msw <- hms::parse_hm("03:30") msf <- hms::parse_hm("05:00") sjl(msw, msf) @@ -228,7 +229,8 @@ msf <- hms::parse_hm("05:15") sjl(msw, msf) #> [1] NA # Expected -## __ Vector example __ +## Vector example + msw <- c(hms::parse_hm("02:05"), hms::parse_hm("04:05")) msf <- c(hms::parse_hm("23:05"), hms::parse_hm("04:05")) sjl(msw, msf) @@ -238,7 +240,8 @@ sjl(msw, msf, abs = FALSE) sjl_rel(msw, msf) # Wrapper function #> [1] "-10800s (~-3 hours)" "0s" # Expected -## __ Using different methods __ +## Using different methods + msw <- hms::parse_hm("19:15") msf <- hms::parse_hm("02:30") sjl(msw, msf, abs = FALSE, method = "difference") @@ -257,7 +260,7 @@ sjl(msw, msf, abs = FALSE, method = "shortest") # default method sjl(msw, msf, abs = FALSE, method = "longer") #> [1] "-81000s (~-22.5 hours)" # Expected -## __ Converting the output to `hms` __ +## Converting the output to `hms` msw <- hms::parse_hm("01:15") msf <- hms::parse_hm("03:25") x <- sjl(msw, msf) @@ -266,7 +269,7 @@ x convert(x, "hms") #> 02:10:00 # Expected -## __ Rounding the output at the seconds level __ +## Rounding the output at the seconds level msw <- hms::parse_hms("04:19:33.1234") msf <- hms::parse_hms("02:55:05") x <- sjl(msw, msf) diff --git a/man/sjl_weighted.Rd b/man/sjl_weighted.Rd index 3a5ea35..afaf9e4 100644 --- a/man/sjl_weighted.Rd +++ b/man/sjl_weighted.Rd @@ -118,7 +118,8 @@ morning shift; \eqn{E} = evening shift; \eqn{N} = night shift. } \examples{ -## __ Scalar example __ +## Scalar example + sjl <- list(sjl_m = lubridate::dhours(1.25), sjl_e = lubridate::dhours(0.5), sjl_n = lubridate::dhours(3)) @@ -133,7 +134,8 @@ n_w <- list(n_w_m = 3, n_w_e = 1, n_w_n = 4) sjl_weighted(sjl, n_w) #> [1] NA # Expected -## __ Vector example __ +## Vector example + sjl <- list(sjl_m = c(lubridate::dhours(2), lubridate::dhours(2.45)), sjl_e = c(lubridate::dhours(3.21), lubridate::as.duration(NA)), sjl_n = c(lubridate::dhours(1.2), lubridate::dhours(5.32))) @@ -141,7 +143,8 @@ n_w <- list(n_w_m = c(1, 3), n_w_e = c(4, 1), n_w_n = c(3, 3)) sjl_weighted(sjl, n_w) #> [1] "8298s (~2.31 hours)" NA # Expected -## __ Checking the first output from vector example __ +## Checking the first output from vector example + if (requireNamespace("stats", quietly = TRUE)) { i <- 1 x <- c(sjl[["sjl_m"]][i], sjl[["sjl_e"]][i], sjl[["sjl_n"]][i]) @@ -150,7 +153,8 @@ if (requireNamespace("stats", quietly = TRUE)) { } #> [1] "8298s (~2.31 hours)" # Expected -## __ Converting the output to hms __ +## Converting the output to hms + sjl <- list(sjl_m = lubridate::dhours(0.25), sjl_e = lubridate::dhours(1.2), sjl_n = lubridate::dhours(4.32)) @@ -160,7 +164,8 @@ sjl_weighted(sjl, n_w) convert(sjl_weighted(sjl, n_w), "hms") #> 01:06:10.285714 # Expected -## __ Rounding the output at the seconds level __ +## Rounding the output at the seconds level + round_time(sjl_weighted(sjl, n_w)) #> [1] "3970s (~1.1 hours)" # Expected round_time(convert(sjl_weighted(sjl, n_w), "hms")) diff --git a/man/sloss_week.Rd b/man/sloss_week.Rd index a511e74..3e20d29 100644 --- a/man/sloss_week.Rd +++ b/man/sloss_week.Rd @@ -118,7 +118,8 @@ more. } \examples{ -## __ Scalar example __ +## Scalar example + sd_w <- lubridate::dhours(6.5) sd_f <- lubridate::dhours(7) wd <- 4 @@ -137,14 +138,16 @@ wd <- 7 sloss_week(sd_w, sd_f, wd) #> [1] NA # Expected -## __ Vector example __ +## Vector example + sd_w <- c(lubridate::dhours(7), lubridate::dhours(8)) sd_f <- c(lubridate::dhours(6.5), lubridate::dhours(8)) wd <- c(2, 0) sloss_week(sd_w, sd_f, wd) #> [1] "2571.42857142857s (~42.86 minutes)" "0s" # Expected -## __ Converting the output to `hms` __ +## Converting the output to `hms` + sd_w <- lubridate::dhours(4) sd_f <- lubridate::dhours(5) wd <- 3 @@ -154,7 +157,8 @@ x convert(x, "hms") #> 01:42:51.428571 # Expected -## __ Rounding the output at the seconds level __ +## Rounding the output at the seconds level + sd_w <- lubridate::dhours(5.8743) sd_f <- lubridate::dhours(7.4324) wd <- 6 diff --git a/man/so.Rd b/man/so.Rd index 80453e3..8369f66 100644 --- a/man/so.Rd +++ b/man/so.Rd @@ -116,7 +116,8 @@ morning shift; \eqn{E} = evening shift; \eqn{N} = night shift. } \examples{ -## __ Scalar example __ +## Scalar example + sprep <- hms::parse_hm("22:00") slat <- lubridate::dminutes(15) so(sprep, slat) @@ -132,7 +133,8 @@ slat <- lubridate::as.duration(NA) so(sprep, slat) #> NA # Expected -## __ Vector example __ +## Vector example + sprep <- c(hms::parse_hm("21:30"), hms::parse_hm("22:15")) slat <- c(lubridate::dminutes(45), lubridate::dminutes(5)) so(sprep, slat) diff --git a/man/sum_time.Rd b/man/sum_time.Rd index a6ca61a..81b4797 100644 --- a/man/sum_time.Rd +++ b/man/sum_time.Rd @@ -100,13 +100,15 @@ it must be considered when doing time arithmetic. } } \examples{ -## __ Linear non-vectorized sum __ +## Linear non-vectorized sum + x <- c(as.POSIXct("2020-01-01 15:00:00"), as.POSIXct("1999-05-04 17:30:00")) y <- lubridate::as.interval(lubridate::dhours(7), as.Date("1970-05-08")) sum_time(x, y, class = "duration") #> [1] "142200s (~1.65 days)" # Expected -## __ Non-vectorized sum in a circular time frame of 24 hours __ +## Non-vectorized sum in a circular time frame of 24 hours + x <- c(lubridate::hours(25), lubridate::dhours(5), lubridate::minutes(50)) sum_time(x, circular = TRUE) #> 06:50:00 # Expected @@ -117,7 +119,8 @@ sum_time(x, circular = TRUE) sum_time(x, circular = TRUE, na.rm = TRUE) #> 02:45:00 # Expected -## __ Linear vectorized sum __ +## Linear vectorized sum + x <- c(lubridate::dhours(6), NA) y <- c(hms::parse_hm("23:00"), hms::parse_hm("10:00")) sum_time(x, y, vectorize = TRUE) @@ -127,7 +130,8 @@ sum_time(x, y, vectorize = TRUE, na.rm = TRUE) #> 29:00:00 # Expected #> 10:00:00 # Expected -## __ Vectorized sum in a circular time frame of 24 hours __ +## Vectorized sum in a circular time frame of 24 hours + x <- c(lubridate::dhours(6), NA) y <- c(hms::parse_hm("23:00"), hms::parse_hm("10:00")) sum_time(x, y, circular = TRUE, vectorize = TRUE) diff --git a/man/tbt.Rd b/man/tbt.Rd index 6111fa2..73cc5d6 100644 --- a/man/tbt.Rd +++ b/man/tbt.Rd @@ -109,7 +109,8 @@ morning shift; \eqn{E} = evening shift; \eqn{N} = night shift. } \examples{ -## __ Scalar example __ +## Scalar example + bt <- hms::parse_hm("22:10") gu <- hms::parse_hm("06:15") tbt(bt, gu) @@ -125,7 +126,8 @@ gu <- hms::parse_hm("07:20") tbt(bt, gu) #> [1] NA # Expected -## __ Vector example __ +## Vector example + bt <- c(hms::parse_hm("23:50"), hms::parse_hm("02:30")) gu <- c(hms::parse_hm("09:30"), hms::parse_hm("11:25")) tbt(bt, gu)