Skip to content

Commit 74a9d60

Browse files
authored
Merge pull request #153 from ACCLAB/dev
v2023.9.12 along with favicon updates
2 parents d206ef7 + fe0d58d commit 74a9d60

28 files changed

+311
-80
lines changed

.Rbuildignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@
1212
^dabestr.Rmd$
1313
^cran-comments\.md$
1414
^revdep$
15+
^CRAN-SUBMISSION$

.github/workflows/R-CMD-check.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
33
on:
44
push:
5-
branches: [dev, master]
5+
branches: [master]
66
pull_request:
77
branches: [dev, master]
88

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ dabestr.Rmd
1414
.RProfile
1515
docs
1616
inst/doc
17-
figures
17+
/figures
18+
CRAN-SUBMISSION

CODE_OF_CONDUCT.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ further defined and clarified by project maintainers.
5555
## Enforcement
5656

5757
Instances of abusive, harassing, or otherwise unacceptable behavior may be
58-
reported by contacting the project team at joseshowh@gmail.com. All
58+
reported by contacting the project team at maiyishan@u.duke.nus.edu. All
5959
complaints will be reviewed and investigated and will result in a response that
6060
is deemed necessary and appropriate to the circumstances. The project team is
6161
obligated to maintain confidentiality with regard to the reporter of an incident.

CONTRIBUTING.md

Lines changed: 45 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,53 @@
11
# Contributing to dabestr
22

3-
## Did you find a bug?
4-
- Ensure the bug was not already reported by searching in [Issues](https://github.com/ACCLAB/dabestr/issues). Check that the bug hasn't been addressed in a closed issue.
3+
The guide is divided into three main pieces:
54

6-
- If the bug isn't being addressed, open a new one. Be sure to include a title and clear description, and a [minimally reproducible code sample](http://adv-r.had.co.nz/Reproducibility.html) demonstrating the expected behavior that is not occurring.
5+
1. Filing a bug in an issue.
6+
1. Filing a feature request in an issue.
7+
1. Suggesting a change via a pull request.
78

8-
## Did you write a patch that fixes a bug?
9-
- Open a new GitHub pull request with the patch.
9+
Please note that dabestr is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By contributing to this project, you agree to abide by its terms.
1010

11-
- Ensure the PR description clearly describes the problem and solution. Include the relevant issue number if applicable.
11+
## Issues
1212

13-
## Do you intend to add a new feature or change an existing one?
14-
- Suggest your change by opening an issue, and adding an Enhancement tag.
15-
- If the maintainers and the community are in favour, create a fork and start writing code.
13+
Ensure the bug was not already reported by searching in [Issues](https://github.com/ACCLAB/dabestr/issues). Be sure to also check that the bug hasn't been addressed in a closed issue.
1614

15+
If the bug isn't being addressed, open a new one.
16+
17+
Be sure to include a title and clear description, and a [minimally reproducible code sample](http://adv-r.had.co.nz/Reproducibility.html) demonstrating the expected behavior that is not occurring.
18+
19+
## Feature Requests
20+
21+
You may suggest by opening an issue and adding an Enhancement tag.
22+
23+
## Pull requests
24+
25+
To contribute a change to dabestr, you follow these steps:
26+
27+
1. Create a fork and make your changes.
28+
1. Issue a PR to the dev branch of dabestr.
29+
1. Discuss the PR.
30+
1. Iterate until either we accept the PR or decide it's not a good fit for dabestr.
31+
32+
Each of these steps are described in more detail below.
33+
34+
If you're not familiar with git or github, please start by reading http://r-pkgs.had.co.nz/git.html
35+
36+
### Guidelines
37+
1. **Clarity**. Ensure PR description clearly describes the problem and the solution. Include the relevant issue number if applicable.
38+
1. **Use dabestr coding style**. dabestr is currently following the [official tidyverse style](http://style.tidyverse.org/). You may choose to do so using the `styler` package by running the following on the code before submitting:
39+
40+
```r
41+
# install.packages("styler")
42+
styler::style_pkg()
43+
```
44+
3. If you're adding new parameters or a new function, you'll also need to document them with [roxygen](https://github.com/klutometis/roxygen). Make sure to re-run `devtools::document()` on the code before submitting.
45+
3. If fixing a bug or adding a new feature, please add a [testthat](https://github.com/r-lib/testthat) unit test.
46+
47+
All PRs require review and approval from at least one member of the dabestr development team before merge.
48+
49+
Lastly, dabestr is a **community** tool for estimation statistics and analysis. We look forward to more robust and more elegant data visualizations from you all!
50+
51+
## Attribution
52+
This Contributing guide is adapted from [ggplot2](https://ggplot2.tidyverse.org)'s [CONTRIBUTING.md](https://github.com/tidyverse/ggplot2/blob/main/CONTRIBUTING.md?plain=1).
1753

18-
dabestr is a community tool for estimation statistics and analysis. We look forward to more robust and more elegant data visualizations from you all!

DESCRIPTION

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ Type: Package
33
Title: Data Analysis using Bootstrap-Coupled Estimation
44
Version: 2023.9.12
55
Authors@R: c(
6+
person("Joses W.", "Ho", email = "joseshowh@gmail.com", role = "aut",
7+
comment = c(ORCID = "0000-0002-9186-6322")),
68
person("Kah Seng", "Lian", email = "kahseng@u.nus.edu", role = c("aut")),
79
person("Zhuoyu", "Wang", email = "wzhuoyu21@u.nus,edu", role = "aut"),
810
person("Jun Yang", "Liao", email = "name@example.com", role = "aut"),
9-
person("Joses W.", "Ho", email = "joseshowh@gmail.com", role = "aut",
10-
comment = c(ORCID = "0000-0002-9186-6322")),
11+
person("Felicia", "Low", role = "aut", email = "lowminhuifelicia@gmail.com"),
1112
person("Tayfun", "Tumkaya", role = "aut",
1213
comment = c(ORCID = "0000-0001-8425-3360")),
13-
person("Felicia", "Low", role = "aut", email = "lowminhuifelicia@gmail.com"),
1414
person("Yishan", "Mai", email = "maiyishan@u.duke.nus.edu", role = c("cre", "ctb"),
1515
comment = c(ORCID = "0000-0002-7199-380X")),
1616
person("Sangyu", "Xu", role = "ctb",

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ recommend that a file or class name and description of purpose be included on
179179
the same “printed page” as the copyright notice for easier identification within
180180
third-party archives.
181181

182-
Copyright [yyyy] [name of copyright owner]
182+
Copyright 2023 dabestr authors
183183

184184
Licensed under the Apache License, Version 2.0 (the "License");
185185
you may not use this file except in compliance with the License.

R/002_df_for_plots.R

Lines changed: 78 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,17 @@
1-
#' Helper functions that generate dfs for tuftelines plot
2-
#'
3-
#' @noRd
4-
#'
1+
#' Generates the dataframe requires for the tufte lines plot component in raw plots.
2+
#'
3+
#' This function returns a dataframe with summary statistics, such as mean, standard
4+
#' deviation and quantiles (depending on the effect size) based on the input dataset.
5+
#'
56
#' @param raw_data The tidy dataset passed to [load()] that was cleaned and altered for plotting.
67
#' @param enquo_x Quosure of x as initially passed to [load()].
78
#' @param enquo_y Quosure of y as initially passed to [load()].
89
#' @param proportional Boolean value as initially passed to [load()].
9-
#' @param float_contrast Default TRUE. If TRUE, a Gardner-Altman plot will be produced.
10-
#' If FALSE, a Cumming estimation plot will be produced.
11-
#' @param enquo_id_col Quosure of id_col as initially passed to [load()].
12-
#' @param idx The list of control-test groupings as initially passed to [load()].
13-
#' @param tufte_lines_df Dataset for the creation of tufte lines.
14-
#' @param proportional_data List of calculations related to the plotting of proportion plots.
15-
#' @param scale_factor_sig Decimal value ranging from 0 to 1 which determines the significance of the scale factor.
16-
#' @param bar_width Numeric value determining the width of the bar in the sankey diagram or proportion plots.
17-
#' @param gap Numeric value determining the space between the bars in the sankey diagram or proportion plots.
18-
#' @param sankey Boolean value determining if the flows between the bar charts will be plotted.
19-
#' @param flow Boolean value determining whether the bars will be plotted in pairs.
20-
#' @param N The number of rows in the proportional dataset.
21-
#' @param proportion_success The proportion or ratio of values that are 1.
22-
#' @param boots Boot result obtained from boot.ci
23-
#' @param x_idx_position Numeric value determining the position of the plots on the x-axis.
10+
#' @param gap Integer value specifying the amount of gap for each tufte line.
11+
#' @param effsize_type String value specifying type of effect size.
2412
#'
25-
#' @details
26-
#' Contains functions `df_for_tufte`, `create_dfs_for_sankey`, `create_dfs_for_xaxis_redraw`, `create_dfs_for_proportion_bar` for generation of dfs.
27-
#'
28-
#' @return
29-
#' Various dfs which is required for the plotting functions to obtain a complete dabest plot.
13+
#' @returns a dataframe for plotting of the tufte lines plot component.
14+
#' @noRd
3015
create_df_for_tufte <- function(raw_data, enquo_x, enquo_y, proportional, gap, effsize_type) {
3116
tufte_lines_df <- raw_data %>%
3217
dplyr::group_by(!!enquo_x) %>%
@@ -67,8 +52,19 @@ create_df_for_tufte <- function(raw_data, enquo_x, enquo_y, proportional, gap, e
6752

6853
return(tufte_lines_df)
6954
}
70-
71-
# Function for creation of df for flow = FALSE plot
55+
#' Generates df for tufte lines plot component for raw plot WITH flow = FALSE.
56+
#'
57+
#' This function rearranges and duplicates rows in a given dataframe (containing
58+
#' summary statistics) in the order of the unlisted given list of vectors.
59+
#'
60+
#' @param idx List of vectors of control-test groupings that determines the arrangement
61+
#' of the final dataframe output.
62+
#' @param tufte_lines_df dataframe for plotting of the tufte lines plot component as
63+
#' generated by [create_df_for_tufte()].
64+
#' @param enquo_x Quosure of x as initially passed to [load()].
65+
#'
66+
#' @returns dataframe
67+
#' @noRd
7268
create_dfs_for_nonflow_tufte_lines <- function(idx,
7369
tufte_lines_df,
7470
enquo_x) {
@@ -84,7 +80,29 @@ create_dfs_for_nonflow_tufte_lines <- function(idx,
8480
return(new_tufte_lines_df)
8581
}
8682

87-
# 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
88106
create_dfs_for_sankey <- function(
89107
float_contrast = FALSE,
90108
raw_data,
@@ -330,7 +348,17 @@ create_dfs_for_sankey <- function(
330348
return(dfs_for_sankeys)
331349
}
332350

333-
# 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
334362
create_dfs_for_xaxis_redraw <- function(idx) {
335363
x_axis_pointer <- 0
336364
xaxis_line_x_vector <- c()
@@ -363,6 +391,16 @@ create_dfs_for_xaxis_redraw <- function(idx) {
363391
return(dfs_for_xaxis_redraw)
364392
}
365393

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
366404
create_dfs_for_proportion_bar <- function(proportion_success, bar_width = 0.3, gap = 0) {
367405
df_for_proportion_bar <- data.frame(
368406
x_failure = NA,
@@ -405,6 +443,18 @@ create_dfs_for_proportion_bar <- function(proportion_success, bar_width = 0.3, g
405443
return(df_for_proportion_bar)
406444
}
407445

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
408458
create_dfs_for_baseline_ec_violin <- function(boots, x_idx_position, float_contrast, flow = TRUE) {
409459
df_for_violin <- data.frame(
410460
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

0 commit comments

Comments
 (0)