Skip to content

Commit

Permalink
Merge pull request #115 from amices/dev
Browse files Browse the repository at this point in the history
Merging for release `ggmice 1.0.0`
  • Loading branch information
hanneoberman authored Jul 24, 2023
2 parents 654f670 + b861dbf commit 7393b0e
Show file tree
Hide file tree
Showing 31 changed files with 493 additions and 128 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
^ggmice\.Rproj$
^\.Rproj\.user$
^LICENSE\.md$
^CONTRIBUTING\.md$
^README\.Rmd$
^\.github$
^doc$
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ jobs:
))
shell: Rscript {0}
env:
LINTR_ERROR_ON_LINT: true
LINTR_ERROR_ON_LINT: false
171 changes: 171 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
<!-- omit in toc -->
# Contributing to `ggmice`

First off, thanks for taking the time to contribute!

All types of contributions are encouraged and valued. See the [Table of Contents](#table-of-contents) for different ways to help and details about how this project handles them. Please make sure to read the relevant section before making your contribution. It will make it a lot easier for us maintainers and smooth out the experience for all involved. The community looks forward to your contributions.

> And if you like the project, but just don't have time to contribute, that's fine. There are other easy ways to support the project and show your appreciation, which we would also be very happy about:
> - Star the project
> - Post about it on Mastodon or Twitter
> - Refer this project in your project's readme
> - Mention the project at local meetups and tell your friends/colleagues
> - Cite the package in your publications
<!-- omit in toc -->
## Table of Contents

- [Code of Conduct](#code-of-conduct)
- [I Have a Question](#i-have-a-question)
- [I Want To Contribute](#i-want-to-contribute)
- [Reporting Bugs](#reporting-bugs)
- [Suggesting Enhancements](#suggesting-enhancements)
- [Code Contributions](#code-contributions)
- [Other contributions](#other-contributions)
- [Styleguides](#styleguides)


## Code of Conduct

This project and everyone participating in it is governed by the
[Code of Conduct](https://github.com/amices/ggmice/blob/main/CODE_OF_CONDUCT.md).
By participating, you are expected to uphold this code. Please report unacceptable behavior
to <[email protected]>.


## I Have a Question

> If you want to ask a question, we assume that you have read the available [Documentation](https://amices.org/ggmice/).
Before you ask a question, it is best to search for existing [Discussions](https://github.com/amices/ggmice/discussions) that might help you. In case you have found a suitable discussion and still need clarification, you can write your question in this discussion. It is also advisable to search the internet for answers first.

If you then still feel the need to ask a question and need clarification, we recommend the following:

- Open a [Discussion](https://github.com/amices/ggmice/discussions/new).
- Provide as much context as you can about what you're running into.
- Provide project and platform versions (e.g. R version), depending on what seems relevant.

We will then take care of the issue as soon as possible.

<!--
You might want to create a separate issue tag for questions and include it in this description. People should then tag their issues accordingly.
Depending on how large the project is, you may want to outsource the questioning, e.g. to Stack Overflow or Gitter. You may add additional contact and information possibilities:
- IRC
- Slack
- Gitter
- Stack Overflow tag
- Blog
- FAQ
- Roadmap
- E-Mail List
- Forum
-->

## I Want To Contribute

> ### Legal Notice <!-- omit in toc -->
> When contributing to this project, you must agree that you have authored 100% of the content, that you have the necessary rights to the content and that the content you contribute may be provided under the project license.
### Reporting Bugs

<!-- omit in toc -->
#### Before Submitting a Bug Report

A good bug report shouldn't leave others needing to chase you up for more information. Therefore, we ask you to investigate carefully, collect information and describe the issue in detail in your report. Please complete the following steps in advance to help us fix any potential bug as fast as possible.

- Make sure that you are using the latest version.
- Determine if your bug is really a bug and not an error on your side e.g. using incompatible environment components/versions (Make sure that you have read the [documentation](https://amices.org/ggmice/). If you are looking for support, you might want to check [this section](#i-have-a-question)).
- To see if other users have experienced (and potentially already solved) the same issue you are having, check if there is not already a bug report existing for your bug or error in the [bug tracker](https://github.com/amices/ggmice/issues?q=label%3Abug).
- Also make sure to search the internet (including Stack Overflow) to see if users outside of the GitHub community have discussed the issue.
- Collect information about the bug:
- Stack trace (Traceback)
- OS, Platform and Version (Windows, Linux, macOS, x86, ARM)
- Version of the interpreter, compiler, SDK, runtime environment, package manager, depending on what seems relevant.
- Possibly your input and the output
- Can you reliably reproduce the issue? And can you also reproduce it with older versions?
- Can you generate a reproducible example with the [`reprex`](https://reprex.tidyverse.org/) package?


<!-- omit in toc -->
#### How Do I Submit a Good Bug Report?

> You must never report security related issues, vulnerabilities or bugs including sensitive information to the issue tracker, or elsewhere in public. Instead sensitive bugs must be sent by email to <[email protected]>.
<!-- You may add a PGP key to allow the messages to be sent encrypted as well. -->
We use GitHub issues to track bugs and errors. If you run into an issue with the project:

- Open an [Issue](https://github.com/amices/ggmice/issues/new). (Since we can't be sure at this point whether it is a bug or not, we ask you not to talk about a bug yet and not to label the issue.)
- Explain the behavior you would expect and the actual behavior.
- Please provide as much context as possible and describe the *reproduction steps* that someone else can follow to recreate the issue on their own. This usually includes your code. For good bug reports you should isolate the problem and create a reduced test case.
- Provide the information you collected in the previous section.
- Please include a reproducible example generated with the [`reprex`](https://reprex.tidyverse.org/) package.

Once it's filed:

- The project team will label the issue accordingly.
- A team member will try to reproduce the issue with your provided steps. If there are no reproduction steps or no obvious way to reproduce the issue, the team will ask you for those steps. Bugs will not be addressed until they can be reproduced.
- If the team is able to reproduce the issue, it will be marked `bug`, as well as possibly other tags (such as `help-wanted`), and the issue will be left to be [implemented by someone](#your-first-code-contribution).

<!-- You might want to create an issue template for bugs and errors that can be used as a guide and that defines the structure of the information to be included. If you do so, reference it here in the description. -->


### Suggesting Enhancements

This section guides you through submitting an enhancement suggestion for `ggmice`, **including completely new features and minor improvements to existing functionality**. Following these guidelines will help maintainers and the community to understand your suggestion and find related suggestions.

<!-- omit in toc -->
#### Before Submitting an Enhancement

- Make sure that you are using the latest version.
- Read the [documentation](https://amices.org/ggmice/) carefully and find out if the functionality is already covered, maybe by an individual configuration.
- Perform a [search](https://github.com/amices/ggmice/issues) to see if the enhancement has already been suggested. If it has, add a comment to the existing issue instead of opening a new one.
- Find out whether your idea fits with the scope and aims of the project. It's up to you to make a strong case to convince the project's developers of the merits of this feature. Keep in mind that we want features that will be useful to the majority of our users and not just a small subset. If you're just targeting a minority of users, consider writing an add-on/plugin library.

<!-- omit in toc -->
#### How Do I Submit a Good Enhancement Suggestion?

Enhancement suggestions are tracked as [GitHub issues](https://github.com/amices/ggmice/issues).

- Use a **clear and descriptive title** for the issue to identify the suggestion.
- Provide a **step-by-step description of the suggested enhancement** in as many details as possible.
- **Describe the current behavior** and **explain which behavior you expected to see instead** and why. At this point you can also tell which alternatives do not work for you.
- You may want to **include screenshots and animated GIFs** which help you demonstrate the steps or point out the part which the suggestion is related to. You can use [this tool](https://www.cockos.com/licecap/) to record GIFs on macOS and Windows, and [this tool](https://github.com/colinkeenan/silentcast) or [this tool](https://github.com/GNOME/byzanz) on Linux. <!-- this should only be included if the project has a GUI -->
- **Explain why this enhancement would be useful** to most `ggmice` users. You may also want to point out the other projects that solved it better and which could serve as inspiration.

<!-- You might want to create an issue template for enhancement suggestions that can be used as a guide and that defines the structure of the information to be included. If you do so, reference it here in the description. -->

### Code Contributions

To become a `ggmice` contributor, please fork the repository and commit your proposed changes to your fork. After pushing the changes and creating a pull request, the `ggmice` team will evaluate your contribution.

If your contribution is related to a [`ggmice` issue](https://github.com/amices/ggmice/issues), include the issue number in your commit message(s) and pull request. If the issue has the label `bug`, please write a unit test for the concerning bug with the [`testthat` package](https://testthat.r-lib.org/).

<!-- TODO
include Setup of env, IDE and typical getting started instructions?
-->

### Other contributions
<!-- TODO
Updating, improving and correcting the documentation
-->
We welcome all contributions to the `ggmice` project.

For example, please interact on the [Discussions](https://github.com/amices/ggmice/discussions) forum, and help fellow `ggmice` users with their questions.

To improve the `ggmice` documentation, please suggest changes to the `README.Rmd` file, the R markdown vignette files in the `vignettes` folder, or use [roxygen2](https://roxygen2.r-lib.org/) to edit the function documentation.


## Styleguides

Please adhere to the [tidyverse style guide](https://style.tidyverse.org/).

We're very happy that you'd like to contribute. To get the appropriate acknowledgement for your contribution, please add your name and [ORCID](https://orcid.org/) to the DESCRIPTION file at the root of the package.


<!-- omit in toc -->
## Attribution

This guide is based on the [CONTRIBUTING.md](https://contributing.md/) generator, [**contributing-gen**](https://generator.contributing.md/).
16 changes: 6 additions & 10 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
Package: ggmice
Title: Visualizations for 'mice' with 'ggplot2'
Version: 0.0.1.9000
Version: 1.0.0
Authors@R: c(
person("Hanne", "Oberman", , "[email protected]", role = c("aut", "cre"),
person("Hanne", "Oberman", email = "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0003-3276-2141")),
person("Utrecht University", role = "fnd"),
person("University Medical Centre Utrecht", role = "fnd"),
person("Thom", "Volker", email = "[email protected]",
role = "ctb", comment = c(ORCID = "0000-0002-2408-7820")),
person("Gerko", "Vink", email = "[email protected]",
role = "ctb", comment = c(ORCID = "0000-0001-9767-1924")),
person("Pepijn", "Vink", email = "[email protected]",
role = "ctb", comment = c(ORCID = "0000-0001-6960-9904")),
person("Jamie", "Wallis", email = "[email protected]",
role = "ctb",comment = c(ORCID = "0000-0003-2765-3813"))
person("Thom", "Volker", role = "ctb", comment = c(ORCID = "0000-0002-2408-7820")),
person("Gerko", "Vink", role = "ctb", comment = c(ORCID = "0000-0001-9767-1924")),
person("Pepijn", "Vink", role = "ctb", comment = c(ORCID = "0000-0001-6960-9904")),
person("Jamie", "Wallis", role = "ctb", comment = c(ORCID = "0000-0003-2765-3813"))
)
Description: Enhance a 'mice' imputation workflow with visualizations for
incomplete and/or imputed data. The plotting functions produce
Expand Down
49 changes: 35 additions & 14 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,37 @@
# `ggmice 0.1.0`

* Vignette updates (PRs #31, #35, #38) and other documentation (PRs #45, #51)
* input validation for data and vrb arguments: error message about log transformations (#34), variable selection actually works (#41, #42, #63), input validation (#85)
* Make jitter work with incomplete categorical variables bug #25
* grid lines #32
* breaking changes in defaults plot_pred and plot_pattern #33, #73, and renamed axes plot_pattern() #57
* plot_pattern() now works with variable called 'y' (#36) and complete data (#44) and completely missing variable (#103).
* new argument plot_pattern() to hide less frequent patterns (#75)
* plot_pred has more arguments and different color scheme (#37)
* ggmice() now displays all imputed data, not just the filled in missing data (i.e. also over-imputed data; #39, PR #54) and is able to match variable names more effectively (#89, PR #90)
* new feature: plot_variance(imp) (#48, PR #56)

# `ggmice 0.0.1`
# ggmice 1.0.0

## Breaking changes

* Default plotting behavior `plot_pattern()` creates missing data pattern plot with square tiles (#74)
* Default plotting behavior `plot_pred()` creates predictor matrix plot with colored tiles and shows predictor values (#71, #74)

## New features

* New plotting function `plot_variance()` visualizes post-imputation variability (#56)
* New optional argument `plot_pred()` shows methods vector with predictor matrix plot (#71)
* New optional argument `plot_pattern()` hides less frequent patterns (#77)
* New optional argument `plot_pattern()` hides legend caption (#111)

## Bug fixes

* The `ggmice()` function now displays all imputed data (incl. over-imputed data; #54)
* The `ggmice()` function now catches errors when `mapping` input contains log-transformation (#80)
* The family of `plot_*` functions now handle vector inputs for `vrb` argument (#80)
* The family of `plot_*` functions now handle `matrix` inputs for `data` argument (#108)
* The family of `plot_*` functions now omit grid lines from tile plots (#35)
* The `plot_pattern()` function now handles any `data.frame` input for `data` argument (#38, #77, #104, #112)


## Minor changes

* Input validation for `data` argument `plot_*` functions (#85)
* Input validation for `vrb` argument `plot_*` functions (#80)
* Input validation for `mapping` argument `ggmice()` (#34, #90)
* Vignette updates (PRs #31, #35, #38) and other documentation (#45, #51)
* The `plot_pattern()` function creates missing data pattern plot with more informative labels (#59, #111)

---

# ggmice 0.0.1

* First release of the package.
2 changes: 1 addition & 1 deletion R/ggmice.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ ggmice <- function(data = NULL,
if (!is.null(mapping$colour)) {
cli::cli_warn(
c(
"The aes() argument 'colour' has a special use in ggmmice() and will be overwritten.",
"The aes() argument 'colour' has a special use in ggmice() and will be overwritten.",
"i" = "Try using 'shape' or 'linetype' for additional mapping, or use faceting."
)
)
Expand Down
24 changes: 13 additions & 11 deletions R/old_friends.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@
#' imp <- mice::mice(mice::nhanes, maxit = 1, printFlag = FALSE)
#' bwplot(imp)
bwplot <- function(...) {
rlang::inform(
"Hint: Did you know, an equivalent figure can be created with `ggmice()`?\n
For example, to plot a variable named 'my_vrb' from a mids object called 'my_mids', run: \n
ggmice(my_mids, ggplot2::aes(x = .imp, y = my_vrb)) +
ggplot2::geom_boxplot() \n\nSee amices.org/ggmice for more info.",
cli::cli_inform(
c(
"Hint: Did you know, an equivalent figure can be created with `ggmice()`?",
"For example, to plot a variable named 'my_vrb' from a mids object called 'my_mids', run: ",
" " = "ggmice(my_mids, ggplot2::aes(x = .imp, y = my_vrb)) +",
" " = "ggplot2::geom_boxplot()",
"i" = "See amices.org/ggmice for more info."),
.frequency = "once",
.frequency_id = "bwplot"
)
Expand All @@ -37,8 +39,8 @@ densityplot <- function(...) {
c(
"Hint: Did you know, an equivalent figure can be created with `ggmice()`?",
"For example, to plot a variable named 'my_vrb' from a mids object called 'my_mids', run:",
"ggmice(my_mids, ggplot2::aes(x = my_vrb, group = .imp)) +
ggplot2::geom_density()",
" " = "ggmice(my_mids, ggplot2::aes(x = my_vrb, group = .imp)) +",
" " = "ggplot2::geom_density()",
"i" = "See amices.org/ggmice for more info."
),
.frequency = "once",
Expand All @@ -62,8 +64,8 @@ stripplot <- function(...) {
c(
"Hint: Did you know, an equivalent figure can be created with `ggmice()`?",
"For example, to plot a variable named 'my_vrb' from a mids object called 'my_mids', run:",
"ggmice(my_mids, ggplot2::aes(x = .imp, y = my_vrb)) +
ggplot2::geom_jitter()",
" " = "ggmice(my_mids, ggplot2::aes(x = .imp, y = my_vrb)) +",
" " = "ggplot2::geom_jitter()",
"i" = "See amices.org/ggmice for more info."
),
.frequency = "once",
Expand All @@ -87,8 +89,8 @@ xyplot <- function(...) {
c(
"Hint: Did you know, an equivalent figure can be created with `ggmice()`?",
"For example, to plot 2 variables named 'my_x' and 'my_y' from a mids object called 'my_mids', run:",
"ggmice(my_mids, ggplot2::aes(x = my_x, y = my_y)) +
ggplot2::geom_point()",
" " = "ggmice(my_mids, ggplot2::aes(x = my_x, y = my_y)) +",
" " = "ggplot2::geom_point()",
"i" = "See amices.org/ggmice for more info."
),
.frequency = "once",
Expand Down
21 changes: 17 additions & 4 deletions R/plot_corr.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,24 @@ plot_corr <-
if (vrb[1] == "all") {
vrb <- names(data)
} else {
vrb <- names(dplyr::select(data, {{vrb}}))
data <- dplyr::select(data, {{vrb}})
vrb <- names(data)
}
# check if any column is constant
constants <- apply(data, MARGIN = 2, function(x) {
all(is.na(x)) || max(x, na.rm = TRUE) == min(x, na.rm = TRUE)
})
if (any(constants)) {
vrb <- names(data[, !constants])
cli::cli_inform(
c(
"No correlations computed for variable(s):",
" " = paste(names(constants[which(constants)]), collapse = ", "),
"x" = "Correlation undefined for constants."
)
)
}

p <- length(vrb)
corrs <- data.frame(
vrb = rep(vrb, each = p),
Expand Down Expand Up @@ -100,6 +116,3 @@ plot_corr <-
}
return(gg)
}

# TODO: add plot for missingness indicators predictors
# TODO: maybe add model.matrix argument to correlation plot?
2 changes: 1 addition & 1 deletion R/plot_flux.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ plot_flux <-
verify_data(data, df = TRUE)
vrb <- substitute(vrb)
if (vrb != "all" && length(vrb) < 2) {
stop("The number of variables should be two or more to compute flux.")
cli::cli_abort("The number of variables should be two or more to compute flux.")
}
if (vrb[1] == "all") {
vrb <- names(data)
Expand Down
Loading

0 comments on commit 7393b0e

Please sign in to comment.