View source: R/define_time_blocks.R
define_time_blocks | R Documentation |
This function defines 'blocks' (i.e., diel periods or seasons) for each day in a time window.
define_time_blocks(
t1 = as.POSIXct("2016-01-01", tz = "UTC"),
t2 = as.POSIXct("2017-01-01", tz = "UTC"),
type = "diel",
type_args = list(),
to_plot = TRUE,
col = NULL
)
t1 |
The start time, in POSIXct format with the time zone specified. |
t2 |
The end time, in POSIXct format with the time zone specified. |
type |
A character input specifying the type of block to define. |
type_args |
A named list of arguments needed to implement |
to_plot |
A logical input defining whether or not the returned dataframe is to be used as an input for plotting (see |
col |
A vector of colours, one for each factor that are added to the dataframe if |
The function returns a dataframe. If to_plot = FALSE
, the dataframe contains 3 columns: date
, time
and level
. If type == "diel"
, levels correspond to day/night; if type == "season"
, levels correspond to the four seasons. If to_plot = TRUE
, x1
, x2
and col
are returned.
Edward Lavender
#### Example (1) define diel blocks between two dates
define_time_blocks(t1 = as.POSIXct("2016-01-01", tz = "UTC"),
t2 = as.POSIXct("2016-01-10", tz = "UTC"),
type = "diel",
type_args = list(lon = 56, lat = -5),
to_plot = FALSE)
#### Example (2) define diel blocks between two dates to plot
define_time_blocks(t1 = as.POSIXct("2016-01-01", tz = "UTC"),
t2 = as.POSIXct("2016-01-10", tz = "UTC"),
type = "diel",
type_args = list(lon = 56, lat = -5),
to_plot = TRUE,
col = c("white", "dimgrey")
)
#### Example (3) define seasonal blocks between two dates
define_time_blocks(t1 = as.POSIXct("2016-01-01", tz = "UTC"),
t2 = as.POSIXct("2016-01-10", tz = "UTC"),
type = "diel",
type_args = list(lon = 56, lat = -5),
to_plot = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.