View source: R/create_series.R
create_series | R Documentation |
tbl_time
object with a sequence of regularly spaced datescreate_series()
allows the user to quickly create a tbl_time
object with
a date
column populated with a sequence of dates.
create_series( time_formula, period = "day", class = "POSIXct", include_end = FALSE, tz = "UTC", as_vector = FALSE )
time_formula |
A period to create the series over.
This is specified as a formula.
See the |
period |
A character specification used for time-based grouping. The
general format to use is Note that you can pass the specification in a flexible way:
This shorthand is available for year, quarter, month, day, hour, minute, second, millisecond and microsecond periodicities. Additionally, you have the option of passing in a vector of dates to use as custom and more flexible boundaries. |
class |
One of |
include_end |
Whether to always include the RHS of the |
tz |
Time zone of the new series. |
as_vector |
Should the series be returned as a vector instead of a tibble? |
# Every day in 2013 create_series(~'2013', 'day') # Every other day in 2013 create_series(~'2013', '2 d') # Every quarter in 2013 create_series(~'2013', '1 q') # Daily series for 2013-2015 create_series('2013' ~ '2015', '1 d') # Minute series for 2 months create_series('2012-01' ~ '2012-02', 'M') # Second series for 2 minutes create_series('2011-01-01 12:10:00' ~ '2011-01-01 12:12:00', 's') # Date class create_series(~'2013', 'day', class = "Date") # yearmon class create_series(~'2013', 'month', class = "yearmon") # hms class. time_formula specified as HH:MM:SS here create_series('00:00:00' ~ '12:00:00', 'second' , class = "hms") # Subsecond series create_series('2013' ~ '2013-01-01 00:00:01', period = "10 millisec") milli <- create_series('2013' ~ '2013-01-01 00:00:01', period = ".1 sec") # Check that 'milli' is correct by running: # options("digits.secs" = 4) # options("digits" = 18) # milli$date # as.numeric(milli$date)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.