smooth_ecd: Create a smoothed (theoretical) Cumulative Distribution...

Description Usage Arguments Value Examples

View source: R/SmootheCDF.R

Description

This function produces a smoothed (theoretical) eCDF plot.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
smooth_ecd(
  data,
  y,
  adj = 1,
  color_var = NULL,
  title = NULL,
  subtitle = NULL,
  compare = FALSE,
  ylab = NULL,
  coord_flip = FALSE,
  plot_only = TRUE,
  show_percent = FALSE
)

Arguments

data

a dataframe containing the data.

y

column reference to determine exceedance entered as an object (without quotes).

adj

adjustment value for smoothing. Select values between 0 and 1.

color_var

optional a grouping variable entered as an object reference.

title

optional title for resulting plot.

subtitle

optional a subtitle for the resulting plot if required.

compare

optional logical value to output the true Empirical Cumulative Distribution Function with the smoothed function, providing a visual comparison.

coord_flip

optional to flip the X and Y axis for visual preference.

plot_only

optional when TRUE a ggtable object is returned without appending the data.

show_percent

optional when TRUE percentage labels are shown on the y axis instead of probability.

Value

Depending on the argument passed to plot_only either a list object is returned when plot_only == FALSE containing a grob object [["plot"]] for plotting and a dataframe [["data"]] for further analysis . A single plot is returned when plot_only == TRUE.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
data(waves)

 plt_a <- smooth_ecd(data = waves,
 y = height_meters)

 plot(plt_a)

 plt_a <- smooth_ecd(data = waves,
 y = height_meters,
 plot_only = FALSE)

 plot(plt_a[["plot"]])

 # Add a grouping variable
 library(dplyr)

 plt_b <- smooth_ecd(data = waves %>%
 mutate(hour = format(date_time, "%H")),
 y = height_meters,
 color_var = hour,
 adj = 1,
 title = "Wave Height Cumulative Distribution",
 subtitle = "By Hour",
 plot_only = FALSE)

 # Access the list objects
 plot(plt_b[["plot"]])
 
 dat <- plt_b[["data"]]

towananalytics/tatools documentation built on Jan. 24, 2022, 7:31 p.m.