
Shows the interrupted time series in Cartesian coordinates and its a periodic/cyclic components.
polar_periodic(
ds_linear,
ds_stage_cycle_polar,
x_name,
y_name,
stage_id_name,
periodic_lower_name = "position_lower",
periodic_upper_name = "position_upper",
palette_dark = NULL,
palette_light = NULL,
change_points = NULL,
change_point_labels = NULL,
draw_observed_line = TRUE,
draw_periodic_band = TRUE,
draw_stage_labels = FALSE,
draw_radius_labels = FALSE,
jagged_point_size = 2,
jagged_line_size = 1,
band_alpha_dark = 0.4,
band_alpha_light = 0.15,
color_labels = "gray50",
color_gridlines = "gray80",
label_color = "orange3",
change_line_alpha = 0.5,
change_line_size = 3,
tick_locations = base::pretty(x = ds_linear[[y_name]]),
graph_floor = min(tick_locations),
graph_ceiling = max(tick_locations),
cardinal_labels = NULL,
origin_label = paste0("The origin represents ", graph_floor,
";\nthe perimeter represents ", graph_ceiling, "."),
plot_margins = c(3.5, 2, 0.5, 2)
)
Returns a grid graphical object (i.e., a grid::grob()
.)
The data.frame to containing the simple linear data. There should be one record per observation.
The data.frame to containing the bands for a single period.
There should be one record per theta per stage. If there are three stages,
this data.frame should have three times as many rows as ds_linear
.
The variable name containing the date.
The variable name containing the dependent/criterion variable.
The variable name indicating which stage the record belongs to.
For example, before the first interruption, the stage_id
is "1", and is "2" afterwards.
The variable name showing the lower bound of a stage's periodic estimate.
The variable name showing the upper bound of a stage's periodic estimate.
A vector of colors used for the dark/heavy graphical elements.
The vector should have one color for each stage_id
value.
If no vector is specified, a default will be chosen, based on the number of stages.
A vector of colors used for the light graphical elements.
The vector should have one color for each stage_id
value.
If no vector is specified, a default will be chosen, based on the number of stages.
A vector of values indicate the interruptions between stages. It typically works best as a Date or a POSIXct class.
The text plotted above each interruption.
A boolean value indicating
if the longitudinal observed line should be plotted (whose values are take from ds_linear
).
A boolean value indicating
if the bands should be plotted (whose values are take from the periodic_lower_name
and periodic_upper_name
fields).
A boolean value indicating
if the stage labels should be plotted (whose values are take from ds_linear
).
A boolean value indicating
if the gridline/radius labels should be plotted (whose values are take from tick_locations
).
The size of the observed data points.
The size of the line connecting the observed data points.
The amount of transparency of the band appropriate for a stage's x values.
The amount of transparency of the band comparison stages for a given x value.
The color for cardinal_labels
and origin_label
.
The color for the gridlines.
The color of the text labels imposed on the line.
The amount of transparency marking each interruption.
The width of a line marking an interruption.
The desired locations for ticks showing the value of the criterion/dependent variable.
The value of the criterion/dependent variable at the center of the polar plot.
The value of the criterion/dependent variable at the outside of the polar plot.
The four labels placed where "North", "East", "South", and "West" typically are.
Explains what the criterion variable's value is at the origin.
Use NULL
if no explanation is desired.
A vector of four numeric
values, specifying the number of lines in the
bottom, left, top and right margins.
requireNamespace("grid")
library(Wats)
ds_linear <-
Wats::county_month_birth_rate_2005_version |>
dplyr::filter(county_name == "oklahoma") |>
augment_year_data_with_month_resolution(date_name = "date")
h_spread <- function(scores) { quantile(x = scores, probs = c(.25, .75)) }
portfolio <- annotate_data(
ds_linear = ds_linear,
dv_name = "birth_rate",
center_function = median,
spread_function = h_spread
)
rm(ds_linear)
polarized <- polarize_cartesian(
portfolio$ds_linear,
portfolio$ds_stage_cycle,
y_name = "birth_rate",
stage_id_name = "stage_id"
)
grid::grid.newpage()
polar_periodic(
ds_linear = polarized$ds_observed_polar,
ds_stage_cycle_polar = polarized$ds_stage_cycle_polar,
y_name = "radius",
stage_id_name = "stage_id",
cardinal_labels = c("Jan1", "Apr1", "July1", "Oct1")
)
grid::grid.newpage()
polar_periodic(
ds_linear = polarized$ds_observed_polar,
ds_stage_cycle_polar = polarized$ds_stage_cycle_polar,
y_name = "radius",
stage_id_name = "stage_id",
draw_periodic_band = FALSE
)
grid::grid.newpage()
polar_periodic(
ds_linear = polarized$ds_observed_polar,
ds_stage_cycle_polar = polarized$ds_stage_cycle_polar,
y_name = "radius",
stage_id_name = "stage_id",
draw_observed_line = FALSE,
cardinal_labels = c("Jan1", "Apr1", "July1", "Oct1")
)
Run the code above in your browser using DataLab