naptime {naptime} | R Documentation |
Safe sleep function
Description
Acceptable inputs:
numeric: time in seconds to nap
POSIXct: time at which the nap should stop (timezone is respected)
character: Date or date time at which nap should stop formatted as yyyy-mm-dd hh:mm:ss, time zone is assumed to be Sys.timezone() and hh:mm:ss is optional as three formats may be missing, cf. lubridate::ymd_hms().
Period: time from now at which the nap should stop
difftime: difference in time to nap
logical: If TRUE, nap for default duration, otherwise don't nap.
NULL: don't nap
generic: error or nap for default duration depending on the option naptime.permissive
Usage
naptime(time, permissive = getOption("naptime.permissive",
permissive_default))
## S4 method for signature 'numeric'
naptime(time, permissive = getOption("naptime.permissive",
permissive_default))
## S4 method for signature 'Period'
naptime(time, permissive = getOption("naptime.permissive",
permissive_default))
## S4 method for signature 'POSIXct'
naptime(time, permissive = getOption("naptime.permissive",
permissive_default))
## S4 method for signature 'difftime'
naptime(time,
permissive = getOption("naptime.permissive", permissive_default))
## S4 method for signature 'logical'
naptime(time, permissive = getOption("naptime.permissive",
permissive_default))
## S4 method for signature ''NULL''
naptime(time, permissive = getOption("naptime.permissive",
permissive_default))
## S4 method for signature 'character'
naptime(time,
permissive = getOption("naptime.permissive", permissive_default))
Arguments
time |
Time to sleep, polymorphic type inputs, leaning towards units as 'seconds' |
permissive |
An optional argument to override the |
Details
The default duration is set with a numeric for the option naptime.default_delay
in seconds (default: 0.1)
Whether a generic input is accepted is determined by the option naptime.permissive
(default: FALSE)
Value
NULL; A side effect of a pause in program execution
Examples
## Not run:
naptime(1)
naptime(difftime("2016-01-01 00:00:01", "2016-01-01 00:00:00"))
## End(Not run)