How to sample the time between the specified range (08:00:00 to 15:00:00). Please help!
Code I tried, but raises error
sample(seq(as.Date.POSIXct('08:00:00'), as.Date.POSIXct('15:00:00')), 20)
Expected:
[1] "08:01:00" "14:00:50" "12:49:50"
How to sample the time between the specified range (08:00:00 to 15:00:00). Please help!
Code I tried, but raises error
sample(seq(as.Date.POSIXct('08:00:00'), as.Date.POSIXct('15:00:00')), 20)
Expected:
[1] "08:01:00" "14:00:50" "12:49:50"
Create sequence of times within the specific duration and sample
. The time would have todays date, to get only time component we use format
.
all_times <- format(seq(as.POSIXct('08:00:00', format = "%T"),
as.POSIXct('15:00:00', format = "%T"), by = "sec"), "%T")
sample(all_times, 3)
#[1] "11:51:16" "09:50:10" "13:09:21"