View source: R/mm_get_timestep.R
mm_get_timestep | R Documentation |
Return the average timestep in days
mm_get_timestep(
datetimes,
format = c("mean", "unique", "modal"),
require_unique = FALSE,
tol = 60/(24 * 60 * 60)
)
datetimes |
a vector of date-times in POSIXct format from which to compute the average timestep |
format |
the format in which to return the timestep. 'mean' always
returns one value; 'unique' may return more than one depending on the
variation in timesteps and the value of |
require_unique |
logical. should it be required that there is exactly
one unique timestep (within the given tolerance |
tol |
if |
{
datetimes <- Sys.time()+ as.difftime(c(0,304,600,900.2,1200,1500,1800), units='secs')
mm_get_timestep(datetimes, 'unique', tol=1/(24*60*60))
mm_get_timestep(datetimes, 'unique', tol=5/(24*60*60))
mm_get_timestep(datetimes, 'unique', tol=10/(24*60*60))
mm_get_timestep(datetimes, 'unique', tol=300/(24*60*60))
mm_get_timestep(datetimes, 'mean')
mm_get_timestep(datetimes, 'mean', require_unique=TRUE, tol=300/(24*60*60))
datetimes <- Sys.time()+ as.difftime(c(-1,0,2,4,5,6,8,10), units='days')
mm_get_timestep(datetimes, 'modal')
mm_get_timestep(c(), 'mean')
mm_get_timestep(c(), 'unique')
mm_get_timestep(c(), 'modal')
## Not run:
# all of these should and do give errors:
mm_get_timestep(datetimes, 'mean', require_unique=TRUE, tol=1/(24*60*60))
mm_get_timestep(datetimes, 'unique', tol=5/(24*60*60), require_unique=TRUE)
mm_get_timestep(c(), 'mean', require_unique=TRUE)
mm_get_timestep(c(), 'unique', require_unique=TRUE)
mm_get_timestep(c(), 'modal', require_unique=TRUE)
## End(Not run)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.