Skip to content

Commit

Permalink
Remove __ from the examples sections
Browse files Browse the repository at this point in the history
  • Loading branch information
danielvartan committed May 23, 2021
1 parent a3343e9 commit 17a6d9e
Show file tree
Hide file tree
Showing 42 changed files with 325 additions and 166 deletions.
18 changes: 12 additions & 6 deletions R/assign_date.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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")
Expand All @@ -134,15 +138,17 @@
#' #> $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")
#' #> [1] "1970-01-01 01:10:00 UTC" # Expected
#' 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)
Expand Down
21 changes: 14 additions & 7 deletions R/convert.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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")
Expand All @@ -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")
Expand All @@ -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")
Expand All @@ -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")
Expand All @@ -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")
Expand All @@ -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
#'
Expand Down
6 changes: 4 additions & 2 deletions R/fd.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,17 @@
#' @export
#'
#' @examples
#' ## __ Scalar example __
#' ## Scalar example
#'
#' fd(5)
#' #> [1] 2 # Expected
#' fd(4)
#' #> [1] 3 # Expected
#' 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))
Expand Down
6 changes: 4 additions & 2 deletions R/gu.R
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,17 @@
#' @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))
#' #> 13:15:00 # Expected
#' 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)
Expand Down
15 changes: 10 additions & 5 deletions R/le_week.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@
#' @export
#'
#' @examples
#' ## __ Scalar example __
#' ## Scalar example
#'
#' le_w <- lubridate::dhours(1.5)
#' le_f <- lubridate::dhours(3.7)
#' wd <- 5
Expand All @@ -75,15 +76,17 @@
#' 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)
#' 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])
Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion R/mctq-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 13 additions & 9 deletions R/ms.R
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@
#' @export
#'
#' @examples
#' ## __ Scalar example __
#' ## Scalar example
#'
#' so <- hms::parse_hm("23:30")
#' sd <- lubridate::dhours(8)
#' ms(so, sd)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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))
Expand All @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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
6 changes: 4 additions & 2 deletions R/pretty_mctq.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
15 changes: 10 additions & 5 deletions R/qplot_walk.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 5 additions & 2 deletions R/raw_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 4 additions & 2 deletions R/round_time.R
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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
Expand Down
Loading

0 comments on commit 17a6d9e

Please sign in to comment.