Skip to content

Commit fe0d58d

Browse files
authored
Merge pull request #152 from sunroofgod/dev
Update favicon and dev documentation
2 parents a4ddde6 + 5ce0638 commit fe0d58d

14 files changed

+131
-27
lines changed

R/002_df_for_plots.R

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,29 @@ create_dfs_for_nonflow_tufte_lines <- function(idx,
8080
return(new_tufte_lines_df)
8181
}
8282

83-
# Function for creation of df for sankey plot
83+
#' Generates df for sankey plot component for raw plot WITH flow = TRUE
84+
#'
85+
#' This function generates data frames necessary for generating
86+
#' sankey diagrams for visualizing flows and proportions of categorical data.
87+
#'
88+
#'
89+
#' @param float_contrast Boolean value determining if a Gardner-Altman plot or Cumming estimation plot will be produced.
90+
#' @param raw_data The tidy dataset passed to [load()] that was cleaned and altered for plotting.
91+
#' @param proportional_data List of calculations related to the plotting of proportion plots.
92+
#' @param enquo_x Quosure of x as initially passed to [load()].
93+
#' @param enquo_y Quosure of y as initially passed to [load()].
94+
#' @param enquo_id_col Quosure of id_col as initially passed to [load()].
95+
#' @param idx List of vectors of control-test groupings that determines the arrangement
96+
#' of the final dataframe output.
97+
#' @param scale_factor_sig Numeric value determining the significance of the scale factor.
98+
#' @param bar_width Numeric value determining the width of the bar in the sankey diagram.
99+
#' @param gap Integer value specifying the amount of gap for each tufte line.
100+
#' @param sankey Boolean value determining if the flows between the bar charts will be plotted.
101+
#' @param flow Boolean value determining whether the bars will be plotted in pairs.
102+
#' @param N Total number of observations or data points in the dataset.
103+
#'
104+
#' @returns dataframe
105+
#' @noRd
84106
create_dfs_for_sankey <- function(
85107
float_contrast = FALSE,
86108
raw_data,
@@ -326,7 +348,17 @@ create_dfs_for_sankey <- function(
326348
return(dfs_for_sankeys)
327349
}
328350

329-
# Function for creation of df for xaxis redraw for float_contrast FALSE plot
351+
#' Generates df for xaxis redraw for float_contrast = FALSE plot
352+
#'
353+
#' This function generates data frames that
354+
#' define the positions of lines and ticks on an x-axis for when float_contrast = FALSE
355+
#' to produce a Cumming estimation plot.
356+
#'
357+
#' @param idx List of vectors of control-test groupings that determines the arrangement
358+
#' of the final dataframe output.
359+
#'
360+
#' @returns dataframe
361+
#' @noRd
330362
create_dfs_for_xaxis_redraw <- function(idx) {
331363
x_axis_pointer <- 0
332364
xaxis_line_x_vector <- c()
@@ -359,6 +391,16 @@ create_dfs_for_xaxis_redraw <- function(idx) {
359391
return(dfs_for_xaxis_redraw)
360392
}
361393

394+
#' Generates df for proportion bar component
395+
#'
396+
#' This function generates data frames to
397+
#' represent bars with proportional data in a graphical display.
398+
#'
399+
#' @param bar_width Numeric value determining the width of the bar in the sankey diagram.
400+
#' @param gap Integer value specifying the amount of gap for each tufte line.
401+
#'
402+
#' @returns dataframe
403+
#' @noRd
362404
create_dfs_for_proportion_bar <- function(proportion_success, bar_width = 0.3, gap = 0) {
363405
df_for_proportion_bar <- data.frame(
364406
x_failure = NA,
@@ -401,6 +443,18 @@ create_dfs_for_proportion_bar <- function(proportion_success, bar_width = 0.3, g
401443
return(df_for_proportion_bar)
402444
}
403445

446+
#' Generates df for baseline violin plot WITH flow = TRUE
447+
#'
448+
#' This function generates data frames to represent
449+
#' data points for plotting violin plots
450+
#'
451+
#' @param boots Boot result obtained from boot.ci
452+
#' @param x_idx_position Numeric value determining the position of the plots on the x-axis.
453+
#' @param float_contrast Boolean value determining if a Gardner-Altman plot or Cumming estimation plot will be produced.
454+
#' @param flow Boolean value determining whether the bars will be plotted in pairs.
455+
#'
456+
#' @return dataframe
457+
#' @noRd
404458
create_dfs_for_baseline_ec_violin <- function(boots, x_idx_position, float_contrast, flow = TRUE) {
405459
df_for_violin <- data.frame(
406460
x = NA,

R/002_plot_api.R

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,19 @@
1-
#' Functions responsible for generation of raw_plot and delta_plot.
1+
#' Generates a ggplot object containing plot components for the rawplot component
2+
#' of an estimation plot.
23
#'
3-
#' @noRd
4+
#' This function takes in a dabest_effectsize_obj object and applies the [create_rawplot_components()]
5+
#' function on the object. Plot components for the rawplot are then produced and returned in the
6+
#' form of a ggplot object.
47
#'
58
#' @param dabest_effectsize_obj A dabest_effectsize_obj created by loading in a
69
#' dabest_obj along with other specified parameters with the [effect_size()] function.
7-
#' @param float_contrast Boolean value determining if a Gardner-Altman plot or Cumming estimation plot will be produced.
10+
#' @param float_contrast Boolean. If TRUE, a Gardner-Altman plot will be produced.
11+
#' If FALSE, a Cumming estimation plot will be produced.
812
#' @param plot_kwargs Adjustment parameters to control and adjust the appearance of the plot.
913
#' (list of all possible adjustment parameters can be found under [plot_kwargs])
1014
#'
11-
#' @details
12-
#' Contains main plotting functions `plot_raw` and `plot_delta` for plotting of the rawdata and effectsize parts.
13-
#'
14-
#' @examples
15-
#' # Loading of the dataset
16-
#' data(twogroup_data)
17-
#'
18-
#' # Preparing the data to be plotted
19-
#' dabest_obj <- load(non_proportional_data, x = Group, y = Measurement, idx = c("Control 1", "Test 1"))
20-
#' dabest_obj.mean_diff <- mean_diff(dabest_obj)
21-
#'
22-
#' # Plotting of dabest_obj.mean_diff (rawplot only)
23-
#' plot_raw(dabest_obj.mean_diff, TRUE)
24-
#'
25-
#' # Plotting of dabest_obj.mean_diff (deltaplot only)
26-
#' plot_delta(dabest_obj.mean_diff, True)
15+
#' @return ggplot object containing plot components for the rawplot.
16+
#' @noRd
2717
plot_raw <- function(dabest_effectsize_obj, float_contrast, plot_kwargs) {
2818
enquo_x <- dabest_effectsize_obj$enquo_x
2919
enquo_y <- dabest_effectsize_obj$enquo_y
@@ -421,8 +411,22 @@ plot_raw <- function(dabest_effectsize_obj, float_contrast, plot_kwargs) {
421411

422412
return(raw_plot)
423413
}
424-
425-
# Delta plot function
414+
#' Generates a ggplot object containing plot components for the deltaplot component
415+
#' of an estimation plot.
416+
#'
417+
#' This function takes in a dabest_effectsize_obj object and applies the [create_deltaplot_components()]
418+
#' function on the object. Plot components for the deltaplot are then produced and returned in the
419+
#' form of a ggplot object.
420+
#'
421+
#' @param dabest_effectsize_obj A dabest_effectsize_obj created by loading in a
422+
#' dabest_obj along with other specified parameters with the [effect_size()] function.
423+
#' @param float_contrast Boolean. If TRUE, a Gardner-Altman plot will be produced.
424+
#' If FALSE, a Cumming estimation plot will be produced.
425+
#' @param plot_kwargs Adjustment parameters to control and adjust the appearance of the plot.
426+
#' (list of all possible adjustment parameters can be found under [plot_kwargs])
427+
#'
428+
#' @return ggplot object containing plot components for the deltaplot.
429+
#' @noRd
426430
plot_delta <- function(dabest_effectsize_obj, float_contrast, plot_kwargs) {
427431
idx <- dabest_effectsize_obj$idx
428432
separated_idx <- idx

R/002_plot_components.R

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,19 @@
22
#
33
# Contains functions `create_rawplot_components`, `create_deltaplot_components` and `create_violinplot_components`.
44

5-
# Function for creation of list of TRUE/FALSE for raw plot components that will be built
5+
#' Generates list of TRUE/FALSE for raw plot components that will be built
6+
#'
7+
#' This function generates a list of booleans determining whether certain
8+
#' plot components will be constructed for the rawplot.
9+
#'
10+
#' @param proportional Boolean value as initially passed to [load()].
11+
#' @param is_paired Boolean value determining if it is a paired plot.
12+
#' @param float_contrast Boolean value determining which plot will be produced. If TRUE, a
13+
#' Gardner-Altman plot will be produced.If FALSE, a Cumming estimation plot will be produced.
14+
#'
15+
#' @return List of booleans for raw plot components
16+
#'
17+
#' @noRd
618
create_rawplot_components <- function(proportional,
719
is_paired,
820
float_contrast) {
@@ -49,7 +61,25 @@ create_rawplot_components <- function(proportional,
4961
return(plot_component)
5062
}
5163

52-
# Function for creation of list of TRUE/FALSE for delta plot components that will be built
64+
#' Generates list of TRUE/FALSE for delta plot components that will be built
65+
#'
66+
#' This function generates a list of booleans determining whether certain
67+
#' plot components will be constructed for the deltaplot.
68+
#'
69+
#' @param proportional Boolean value as initially passed to [load()].
70+
#' @param is_paired Boolean value determining if it is a paired plot.
71+
#' @param float_contrast Boolean value determining which plot will be produced. If TRUE, a
72+
#' Gardner-Altman plot will be produced.If FALSE, a Cumming estimation plot will be produced.
73+
#' @param is_colour Boolean value determining if there is a colour column for the plot.
74+
#' @param delta2 Boolean value determining if delta-delta analysis for
75+
#' 2 by 2 experimental designs is conducted.
76+
#' @param show_zero_dot Boolean value determining if there is a dot on
77+
#' the zero line of the effect size for the control-control group.
78+
#' @param flow Boolean value determining whether the bars will be plotted in pairs.
79+
#' @param show_baseline_ec Boolean value determining whether the baseline curve is shown.
80+
#'
81+
#' @return List of booleans for delta plot components
82+
#' @noRd
5383
create_deltaplot_components <- function(proportional,
5484
is_paired,
5585
float_contrast,
@@ -92,7 +122,23 @@ create_deltaplot_components <- function(proportional,
92122
return(plot_component)
93123
}
94124

95-
# Function for creation of list of values of the violin plot components that will be built
125+
#' Generates list of values for the violin plot components that will be built
126+
#'
127+
#' This function generates the data and metadata necessary to create a
128+
#' violin plot with specific characteristics
129+
#'
130+
#' @param boots Boot result obtained from boot.ci
131+
#' @param idx List of vectors of control-test groupings that determines the arrangement
132+
#' of the final dataframe output.
133+
#' @param float_contrast Boolean value determining if a Gardner-Altman plot or
134+
#' Cumming estimation plot will be produced.
135+
#' @param delta_y_max Max y limits for the delta-delta plot
136+
#' @param delta_y_min Min y limits for the delta-delta plot
137+
#' @param flow Boolean value determining whether the bars will be plotted in pairs.
138+
#' @param zero_dot Boolean value determining if the zero dot will be constructed.
139+
#'
140+
#' @return List of components essential for the violinplot.
141+
#' @noRd
96142
create_violinplot_components <- function(boots,
97143
idx,
98144
float_contrast,

man/figures/logo.png

1.7 KB
Loading

man/figures/logo.svg

Lines changed: 1 addition & 1 deletion
Loading
-24 Bytes
Loading
95 Bytes
Loading
379 Bytes
Loading
41 Bytes
Loading
-35 Bytes
Loading

0 commit comments

Comments
 (0)