Last chance! 50% off unlimited learning
Sale ends in
sample_dates
draws a sample of
n
random dates from a given range.
sample_dates(n = 1, from = "1970-01-01", to = Sys.Date())
Number dates to draw.
Default: n = 1
.
Earliest date (as string).
Default: from = "1970-01-01"
.
Latest date (as string).
Default: to = Sys.Date()
.
By default, sample_dates
draws n = 1
random date in the range
from = "1970-01-01"
to = Sys.Date()
(current date).
Other random functions:
coin()
,
dice_2()
,
dice()
,
sample_times()
# NOT RUN {
sample_dates()
sort(sample_dates(n = 10))
sort(sample_dates(n = 10, from = "2020-02-28", to = "2020-03-01")) # 2020 is a leap year
# Note: Oddity with sample():
sort(sample_dates(n = 10, from = "2020-01-01", to = "2020-01-01")) # range of 0!
# see sample(9:9, size = 10, replace = TRUE)
# }
Run the code above in your browser using DataLab