printDuration: [+!] Evaluate how much time passed

Description Usage Arguments Value Author(s) See Also Examples

View source: R/printDuration.R

Description

Evaluate and print difference between moment of time at which time interval began (usually captured by function Sys.time some time ago) and the present (i.e., moment when function printDuration is called).

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
printDuration(
  Start,
  Message = "Analysis completed in",
  returnString = FALSE,
  End = Sys.time()
)

Duration(
  Start,
  Message = "Analysis completed in",
  print = FALSE,
  End = Sys.time()
)

time_elapsed(start = stop("'start' is missing"), end = Sys.time())

Arguments

Start, start

Moment of time which is treated as the beggining (object of class POSIXct).

Message

Message before time stamp that describes it. Default is "Duration of analysis:"

returnString

If TRUE, returns result as a string. If FALSE (default), function pander prints the result.

End, end

Moment of time which is treated as the end (object of class POSIXct).

print

(logical) should the result be printed using package pander?

Value

Text indicating how much time has passed (either printed in console or as a string).

Author(s)

Vilmantas Gegzna

See Also

difftime

Other spMisc utilities: bru(), clc(), clear(), fCap(), isFALSE(), list_AddRm(), make.filenames(), open_wd(), regexp2df(), st01()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
Start <-  Sys.time()

Start
## [1] "2016-02-12 16:15:09 UTC"

class(Start)
## [1] "POSIXct" "POSIXt"

printDuration(Start)
## Duration of analysis: 23.3 secs

printDuration(Start,"From start till now")
## From start till now 39.2 secs

my_duration <- printDuration(Start)
my_duration
## NULL

my_duration <- printDuration(Start, returnString = TRUE)
my_duration
## [1] "Analysis completed in 2.4 mins"

GegznaV/spMisc documentation built on April 26, 2020, 5:59 p.m.