Description Usage Arguments Value Examples
Produce random dates within a particular range of possibilities
1 2 | sample_date(year_min, year_max = year_min, month_min = 1, month_max = 12,
day_min = 1, day_max = 31, n, .p = null_predicate, quiet = FALSE)
|
year_min |
Integer. Minimum year (Required) |
year_max |
Integer. Maximum year |
month_min |
Integer. Minimum month |
month_max |
Integer. Maximum month |
day_min |
Integer. Minimum day |
day_max |
Integer. Maximum day |
n |
Integer. Number of permuations to return. (Required) |
.p |
An optional |
quiet |
Boolean. Display messages when regenerating illegal dates? |
A vector of POSIXct values
1 2 3 4 5 6 7 8 9 10 11 12 | set.seed(100)
# Generate random dates within the year 1930
sample_date(1930, n = 5)
# Dates in March 1930
sample_date(1930, month_min = 3, month_max = 3, n = 5)
# Dates between a given range
sample_date(year_min = 1930, year_max = 1931, day_min = 25, day_max = 31, n = 5)
# Use a predicate function to return only Mondays
sample_date(1930, n = 5, .p = is_monday)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.