Despite your answer to your question, I will also respond. This is for two reasons.
In the question data each day is repeated 6 times and with by = 0.5
only repeats two.
There are also the missing hours in your reply.
First, I start by creating a vector of dates. I've modified it a bit with% of% to make the seq/as.Date
increment more clear. The second instruction repeats every day such 6 times.
Note that by = "days"
is a base R function, so I called this vector data
.
Data <- seq(as.Date('2013/01/01', "%Y/%m/%d"), as.Date('2018/05/31', "%Y/%m/%d"), by = "days")
Data <- rep(Data, each = 6)
Second, I create a class vector Data
with the hours. There is also a "character"
function but in this case it can not be used because the hour increments are not constant, the question time differences are seq.POSIXt
.
Hora <- c("0:00", "1:00", "4:00", "8:00", "12:00", "18:00")
Hora <- rep(Hora, length.out = length(Data))
Finally, I create a 1 3 4 4 6
with the two vectors in the same column.
dados <- data.frame(Data = as.POSIXct(paste(Data, Hora), format = "%Y-%m-%d %H:%M"))
head(dados, n = 20)
# Data
#1 2013-01-01 00:00:00
#2 2013-01-01 01:00:00
#3 2013-01-01 04:00:00
#4 2013-01-01 08:00:00
#5 2013-01-01 12:00:00
#6 2013-01-01 18:00:00
#7 2013-01-02 00:00:00
#8 2013-01-02 01:00:00
#9 2013-01-02 04:00:00
#10 2013-01-02 08:00:00
#11 2013-01-02 12:00:00
#12 2013-01-02 18:00:00
#13 2013-01-03 00:00:00
#14 2013-01-03 01:00:00
#15 2013-01-03 04:00:00
#16 2013-01-03 08:00:00
#17 2013-01-03 12:00:00
#18 2013-01-03 18:00:00
#19 2013-01-04 00:00:00
#20 2013-01-04 01:00:00