Skip to content

Commit

Permalink
Merge pull request #98 from egouldo/tidy_styler
Browse files Browse the repository at this point in the history
tidy styler
  • Loading branch information
egouldo authored Aug 10, 2024
2 parents c9081c7 + 83a0d07 commit ccbcadb
Show file tree
Hide file tree
Showing 90 changed files with 4,251 additions and 3,108 deletions.
47 changes: 47 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Contributing to ManyEcoEvo

This outlines how to propose a change to ManyEcoEvo.
For a detailed discussion on contributing to this and other tidyverse packages, please see the [development contributing guide](https://rstd.io/tidy-contrib) and our [code review principles](https://code-review.tidyverse.org/).

## Fixing typos

You can fix typos, spelling mistakes, or grammatical errors in the documentation directly using the GitHub web interface, as long as the changes are made in the _source_ file.
This generally means you'll need to edit [roxygen2 comments](https://roxygen2.r-lib.org/articles/roxygen2.html) in an `.R`, not a `.Rd` file.
You can find the `.R` file that generates the `.Rd` by reading the comment in the first line.

## Bigger changes

If you want to make a bigger change, it's a good idea to first file an issue and make sure someone from the team agrees that it’s needed.
If you’ve found a bug, please file an issue that illustrates the bug with a minimal
[reprex](https://www.tidyverse.org/help/#reprex) (this will also help you write a unit test, if needed).
See our guide on [how to create a great issue](https://code-review.tidyverse.org/issues/) for more advice.

### Pull request process

* Fork the package and clone onto your computer. If you haven't done this before, we recommend using `usethis::create_from_github("egouldo/ManyEcoEvo", fork = TRUE)`.

* Install all development dependencies with `devtools::install_dev_deps()`, and then make sure the package passes R CMD check by running `devtools::check()`.
If R CMD check doesn't pass cleanly, it's a good idea to ask for help before continuing.
* Create a Git branch for your pull request (PR). We recommend using `usethis::pr_init("brief-description-of-change")`.

* Make your changes, commit to git, and then create a PR by running `usethis::pr_push()`, and following the prompts in your browser.
The title of your PR should briefly describe the change.
The body of your PR should contain `Fixes #issue-number`.

* For user-facing changes, add a bullet to the top of `NEWS.md` (i.e. just below the first header). Follow the style described in <https://style.tidyverse.org/news.html>.

### Code style

* New code should follow the tidyverse [style guide](https://style.tidyverse.org).
You can use the [styler](https://CRAN.R-project.org/package=styler) package to apply these styles, but please don't restyle code that has nothing to do with your PR.

* We use [roxygen2](https://cran.r-project.org/package=roxygen2), with [Markdown syntax](https://cran.r-project.org/web/packages/roxygen2/vignettes/rd-formatting.html), for documentation.

* We use [testthat](https://cran.r-project.org/package=testthat) for unit tests.
Contributions with test cases included are easier to accept.

## Code of Conduct

Please note that the ManyEcoEvo project is released with a
[Contributor Code of Conduct](CODE_OF_CONDUCT.md). By contributing to this
project you agree to abide by its terms.
16 changes: 16 additions & 0 deletions .github/ISSUE_TEMPLATE/issue_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
name: Bug report or feature request
about: Describe a bug you've seen or make a case for a new feature
---

Please briefly describe your problem and what output you expect. If you have a question, please don't use this form. Instead, ask on <https://stackoverflow.com/> or <https://community.rstudio.com/>.

Please include a minimal reproducible example (AKA a reprex). If you've never heard of a [reprex](http://reprex.tidyverse.org/) before, start by reading <https://www.tidyverse.org/help/#reprex>.

For more advice on how to write a great issue, see <https://code-review.tidyverse.org/issues/>.

Brief description of the problem

```r
# insert reprex here
```
35 changes: 35 additions & 0 deletions .github/SUPPORT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Getting help with ManyEcoEvo

Thanks for using ManyEcoEvo!
Before filing an issue, there are a few places to explore and pieces to put together to make the process as smooth as possible.

## Make a reprex

Start by making a minimal **repr**oducible **ex**ample using the [reprex](https://reprex.tidyverse.org/) package.
If you haven't heard of or used reprex before, you're in for a treat!
Seriously, reprex will make all of your R-question-asking endeavors easier (which is a pretty incredible ROI for the five to ten minutes it'll take you to learn what it's all about).
For additional reprex pointers, check out the [Get help!](https://www.tidyverse.org/help/) section of the tidyverse site.

## Where to ask?

Armed with your reprex, the next step is to figure out [where to ask](https://www.tidyverse.org/help/#where-to-ask).

* If it's a question: start with [community.rstudio.com](https://community.rstudio.com/), and/or StackOverflow. There are more people there to answer questions.

* If it's a bug: you're in the right place, [file an issue](https://github.com/egouldo/ManyEcoEvo/issues/new).

* If you're not sure: let the community help you figure it out!
If your problem _is_ a bug or a feature request, you can easily return here and report it.

Before opening a new issue, be sure to [search issues and pull requests](https://github.com/egouldo/ManyEcoEvo/issues) to make sure the bug hasn't been reported and/or already fixed in the development version.
By default, the search will be pre-populated with `is:issue is:open`.
You can [edit the qualifiers](https://help.github.com/articles/searching-issues-and-pull-requests/) (e.g. `is:pr`, `is:closed`) as needed.
For example, you'd simply remove `is:open` to search _all_ issues in the repo, open or closed.

## What happens next?

To be as efficient as possible, development of tidyverse packages tends to be very bursty, so you shouldn't worry if you don't get an immediate response.
Typically we don't look at a repo until a sufficient quantity of issues accumulates, then there’s a burst of intense activity as we focus our efforts.
That makes development more efficient because it avoids expensive context switching between problems, at the cost of taking longer to get back to you.
This process makes a good reprex particularly important because it might be multiple months between your initial report and when we start working on it.
If we can’t reproduce the bug, we can’t fix it!
85 changes: 85 additions & 0 deletions .github/workflows/pr-commands.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
issue_comment:
types: [created]

name: pr-commands.yaml

permissions: read-all

jobs:
document:
if: ${{ github.event.issue.pull_request && (github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') && startsWith(github.event.comment.body, '/document') }}
name: document
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
steps:
- uses: actions/checkout@v4

- uses: r-lib/actions/pr-fetch@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::roxygen2
needs: pr-document

- name: Document
run: roxygen2::roxygenise()
shell: Rscript {0}

- name: commit
run: |
git config --local user.name "$GITHUB_ACTOR"
git config --local user.email "[email protected]"
git add man/\* NAMESPACE
git commit -m 'Document'
- uses: r-lib/actions/pr-push@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}

style:
if: ${{ github.event.issue.pull_request && (github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') && startsWith(github.event.comment.body, '/style') }}
name: style
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
steps:
- uses: actions/checkout@v4

- uses: r-lib/actions/pr-fetch@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}

- uses: r-lib/actions/setup-r@v2

- name: Install dependencies
run: install.packages("styler")
shell: Rscript {0}

- name: Style
run: styler::style_pkg()
shell: Rscript {0}

- name: commit
run: |
git config --local user.name "$GITHUB_ACTOR"
git config --local user.email "[email protected]"
git add \*.R
git commit -m 'Style'
- uses: r-lib/actions/pr-push@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
10 changes: 10 additions & 0 deletions .lintr
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
linters: linters_with_defaults(
commented_code_linter = NULL,
object_usage_linter = NULL,
seq_linter = NULL, #fine for forloops, not great in mutate calls
line_length_linter(120)
) # see vignette("lintr")
encoding: "UTF-8"
exclusions: list(
"data-raw/analyst_data"
)
87 changes: 41 additions & 46 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,76 +1,71 @@
Package: ManyEcoEvo
Title: Meta-analyse data from 'Many-Analysts' style studies
Version: 2.3.0
Authors@R: c(person(given = "Elliot",
family = "Gould",
email = "[email protected]",
role = c("aut", "cre"),
comment = c(ORCID = "https://orcid.org/0000-0002-6585-538X")),
person(given = "Hannah S.",
family = "Fraser",
role = "aut",
comment = c(ORCID = "https://orcid.org/0000-0003-2443-4463")),
person(given = "Shinichi",
family = "Nakagawa",
role = "aut",
comment = c(ORCID = "https://orcid.org/0000-0002-7765-5182")),
person(given = "Timothy H.",
family = "Parker",
role = "aut",
comment = c(ORCID = "https://orcid.org/0000-0003-2995-5284"))
)
Description: The ManyEcoEvo package provides a set of functions for
aiding data cleaning, preparation and conducting analysis for
multi-analyst style studies. It also contains datasets from the
ManyEcoEvo project for reproducing the ManyEcoEvo analysis.
Authors@R: c(
person("Elliot", "Gould", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "https://orcid.org/0000-0002-6585-538X")),
person("Hannah S.", "Fraser", role = "aut",
comment = c(ORCID = "https://orcid.org/0000-0003-2443-4463")),
person("Shinichi", "Nakagawa", role = "aut",
comment = c(ORCID = "https://orcid.org/0000-0002-7765-5182")),
person("Timothy H.", "Parker", role = "aut",
comment = c(ORCID = "https://orcid.org/0000-0003-2995-5284"))
)
Description: The ManyEcoEvo package provides a set of functions for aiding
data cleaning, preparation and conducting analysis for multi-analyst
style studies. It also contains datasets from the ManyEcoEvo project
for reproducing the ManyEcoEvo analysis.
License: GPL (>= 3)
URL: https://github.com/egouldo/ManyEcoEvo,
https://egouldo.github.io/ManyEcoEvo/
BugReports: https://github.com/egouldo/ManyEcoEvo/issues
Depends:
R (>= 2.10)
Imports:
betapart,
dplyr,
tidyselect,
pointblank,
tibble,
cli,
data.table,
dplyr,
forcats,
fs,
glue,
here,
lifecycle,
lme4,
magrittr,
metafor,
naniar,
magrittr,
tidyr,
rlang,
pointblank,
purrr,
tidyselect
rlang,
tibble,
tidyr,
tidyselect,
tidyselect,
withr
Suggests:
targets,
qs,
broom.mixed,
metaviz,
ggeffects,
knitr,
metaviz,
parameters,
performance,
parsnip,
workflows,
timetk,
recipes,
sae,
performance,
pracma,
progress,
knitr,
rmarkdown
qs,
recipes,
rmarkdown,
sae,
targets,
timetk,
workflows
VignetteBuilder:
knitr
Remotes:
daniel1noble/orchaRd,
NightingaleHealth/ggforestplot
daniel1noble/orchaRd,
NightingaleHealth/ggforestplot
Encoding: UTF-8
LazyData: false
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.2
URL: https://github.com/egouldo/ManyEcoEvo,
https://egouldo.github.io/ManyEcoEvo/
BugReports: https://github.com/egouldo/ManyEcoEvo/issues
VignetteBuilder: knitr
4 changes: 2 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ import(metafor)
import(recipes)
import(rlang)
import(see)
import(tidyr)
importFrom(EnvStats,stat_n_text)
importFrom(broom,tidy)
importFrom(broom.mixed,tidy)
Expand Down Expand Up @@ -141,6 +142,7 @@ importFrom(dplyr,summarise)
importFrom(forcats,fct_relevel)
importFrom(ggplot2,ggplot)
importFrom(glue,glue)
importFrom(lifecycle,deprecated)
importFrom(lme4,lmer)
importFrom(magrittr,"%>%")
importFrom(metaviz,viz_funnel)
Expand Down Expand Up @@ -177,7 +179,5 @@ importFrom(tibble,tibble)
importFrom(tidyr,hoist)
importFrom(tidyr,pivot_longer)
importFrom(tidyr,pivot_wider)
importFrom(tidyr,separate)
importFrom(tidyr,unite)
importFrom(tidyr,unnest)
importFrom(timetk,step_box_cox)
9 changes: 9 additions & 0 deletions R/ManyEcoEvo-package.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#' @keywords internal
"_PACKAGE"

## usethis namespace: start
#' @import rlang
#' @importFrom glue glue
#' @importFrom lifecycle deprecated
## usethis namespace: end
NULL
32 changes: 17 additions & 15 deletions R/Z_VZ_preds.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,28 @@
#' @return A tibble with columns \code{Z} and \code{VZ}
#' @family Analysis-level functions
#' @export
Z_VZ_preds <- function(yi, yi_se, mu_p, sd_p ){
#TODO should we pass in whole DF as arg instead of yi + yi_se??
Z_VZ_preds <- function(yi, yi_se, mu_p, sd_p) {
# TODO should we pass in whole DF as arg instead of yi + yi_se??
# We want to be able to keep the values linked to their corresponding
# scenario_value!
na_args <- purrr::discard(c(yi, yi_se, mu_p, sd_p), is.na) %>%
na_args <- purrr::discard(c(yi, yi_se, mu_p, sd_p), is.na) %>%
length()
if(na_args < 3){

if (na_args < 3) {
cli::cli_alert_danger("Required values for computing Z/VZ predictions missing:")
cli::cli_alert_warning("Returning {.val NA} for quadrupple:")
cli::cli_ol(c("yi {.val {yi}},",
"yi_se {.val {yi_se}},",
"mu_p {.val {mu_p}}",
"sd_p {.val {sd_p}}"))
return(NA) #TODO single NA value OR, tibble with NA's?
cli::cli_ol(c(
"yi {.val {yi}},",
"yi_se {.val {yi_se}},",
"mu_p {.val {mu_p}}",
"sd_p {.val {sd_p}}"
))
return(NA)
}


Z <- (yi - mu_p) / sd_p
VZ <- yi_se / sd_p
return(tibble(Z, VZ))
}

return(tibble(Z, VZ))
}
Loading

0 comments on commit ccbcadb

Please sign in to comment.