How to Generate Random Sample of POSIXct Dates & Times in R (Example) | seq() & sample() Functions

preview_player
Показать описание
R code of this video:

datetime_sequence <- seq(as.POSIXct('2020/01/01'), # Create sequence of dates
as.POSIXct('2030/01/01'),
by = "10 mins")
head(datetime_sequence) # Print head of sequence of dates

datetime_random <- sample(datetime_sequence, # Sample random dates from sequence
size = 500,
replace = TRUE)
head(datetime_random) # Print head of random dates

Follow me on Social Media:

Рекомендации по теме
Комментарии
Автор

Hi, glad to see a pandas video here, thanks for a very good video, your videos are really appreciated.
Unfortunately, nothing works for me, this is the first time I use R!
Do you can help me please, I have excel files with Timestamp, but sometimes there are some errors like


05/12/2021 4:00
05/12/2021 5:00
05/12/2021 7:00
as you notice we do not have 05/12/2021 6:00
or sometimes we have dopple value
05/12/2021 6:00
05/12/2021 6:00
I do that manually, do you know if I can do that in Python, I want to check data before concatenating!
Many thanks in advance.

gretabaumann