5
How do I generate a list with dates, for example, starting in 2011-07-01 and ending in 2011-10-31 ?
5
How do I generate a list with dates, for example, starting in 2011-07-01 and ending in 2011-10-31 ?
7
Through function seq
:
datas_dia <- seq(from=as.Date("2011-07-01"), to=as.Date("2011-10-31"), by="day")
datas_semana <- seq(from=as.Date("2011-07-01"), to=as.Date("2011-10-31"), by="week")
datas_mes <- seq(from=as.Date("2011-07-01"), to=as.Date("2011-10-31"), by="month")
in which
as.Date
converts the string to the date format
seq
creates the sequence
from
tells you where the sequence begins
to
tells you where the sequence ends
by
determines the sequence increment (in my example, increments are day, week and month, respectively)
Browser other questions tagged r
You are not signed in. Login or sign up in order to post.
Thank you. This monthly sequence was just where I was most getting complicated. I tried to create date without the days, only with year and month, but I could not.
– Filipe Vargas
I’m glad it worked out. Consider vote and accept my answer if she has, in fact, solved your problem.
– Marcus Nunes