Skip to content

Commit

Permalink
Updates for tidyverse (#255)
Browse files Browse the repository at this point in the history
* updates to `case_*()` functions

* sync with ggstatsplot workflows

* fix

* fix actions URL on README

* inline more piped calls

* bump testthat version

* Update R-CMD-check-hard.yaml

* test hygiene

* fix test warnings

* Update helper-state.R
  • Loading branch information
IndrajeetPatil authored Oct 11, 2023
1 parent 53473db commit eea191f
Show file tree
Hide file tree
Showing 30 changed files with 103 additions and 94 deletions.
2 changes: 2 additions & 0 deletions .covrignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
R/deprec-*.R
R/compat-*.R
5 changes: 2 additions & 3 deletions .github/workflows/R-CMD-check-hard.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,10 @@ jobs:

- uses: r-lib/actions/setup-pandoc@v2
with:
pandoc-version: "3.1.7"
pandoc-version: "3.1.8"

- uses: r-lib/actions/setup-r@v2
with:
r-version: "release"
http-user-agent: "release"
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
Expand All @@ -44,6 +42,7 @@ jobs:
any::knitr
any::rcmdcheck
any::rmarkdown
any::curl
any::testthat
needs: check

Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/R-CMD-check-strict.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,19 @@ jobs:
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes
_R_CHECK_CRAN_INCOMING_REMOTE_: true
_R_CHECK_CRAN_INCOMING_: true

steps:
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2
with:
pandoc-version: "3.1.7"
pandoc-version: "3.1.8"

- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
http-user-agent: "release"
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
Expand Down
15 changes: 8 additions & 7 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,16 @@ jobs:
fail-fast: false
matrix:
config:
#- {os: macOS-latest, r: 'devel'}
#- { os: macOS-latest, r: "release" }
- { os: macOS-latest, r: "oldrel-1" }
# Checks are not run on R-devel because they are already run in
# `R-CMD-check-strict` workflow

#- { os: macos-latest, r: 'devel' }
#- { os: macos-latest, r: "release" }
- { os: macos-latest, r: "oldrel-1" }

#- { os: windows-latest, r: "devel" }
- { os: windows-latest, r: "release" }
- {os: windows-latest, r: 'oldrel-1'}
- { os: windows-latest, r: "oldrel-1" }

#- { os: ubuntu-latest, r: "devel" }
- { os: ubuntu-latest, r: "release" }
Expand All @@ -39,12 +42,11 @@ jobs:

- uses: r-lib/actions/setup-pandoc@v2
with:
pandoc-version: "3.1.7"
pandoc-version: "3.1.8"

- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
http-user-agent: "release"
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
Expand All @@ -57,4 +59,3 @@ jobs:
- uses: r-lib/actions/check-r-package@v2
with:
upload-snapshots: true
upload-results: true
1 change: 1 addition & 0 deletions .github/workflows/check-all-examples.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ jobs:
extra-packages: |
any::devtools
local::.
needs: check

- name: Run examples
run: |
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/check-link-rot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@ jobs:

- uses: r-lib/actions/setup-pandoc@v2
with:
pandoc-version: "3.1.7"
pandoc-version: "3.1.8"

- uses: r-lib/actions/setup-r@v2
with:
r-version: "devel"
http-user-agent: "release"
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
Expand All @@ -35,7 +34,8 @@ jobs:
dependencies: '"hard"'
extra-packages: |
any::rcmdcheck
r-lib/urlchecker
any::urlchecker
needs: check

- name: Run URL checker
run: |
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/check-random-test-order.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ jobs:
- uses: r-lib/actions/setup-r@v2
with:
r-version: "devel"
http-user-agent: "release"
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/check-spelling.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ on:
branches: [main, master]
pull_request:
branches: [main, master]
schedule:
# * is a special character in YAML so you have to quote this string
# Trigger once a week at 00:00 on Sunday
- cron: "0 0 * * SUN"

name: check-spelling

Expand All @@ -17,12 +21,10 @@ jobs:

- uses: r-lib/actions/setup-pandoc@v2
with:
pandoc-version: "3.1.7"
pandoc-version: "3.1.8"

- uses: r-lib/actions/setup-r@v2
with:
r-version: "devel"
http-user-agent: "release"
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/html-5-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ jobs:
- uses: r-lib/actions/setup-r@v2
with:
r-version: "devel"
http-user-agent: "release"
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/pkgdown-no-suggests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,10 @@ jobs:

- uses: r-lib/actions/setup-pandoc@v2
with:
pandoc-version: "3.1.7"
pandoc-version: "3.1.8"

- uses: r-lib/actions/setup-r@v2
with:
r-version: "release"
http-user-agent: "release"
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/styler.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
- name: Style package
run: |
options(crayon.enabled = TRUE)
styler::style_pkg(filetype = c(".R", ".Rmd", ".Rmarkdown", ".Rnw"))
styler::style_pkg(filetype = c(".qmd", ".R", ".Rmd", ".Rmarkdown", ".Rnw"))
shell: Rscript {0}

- name: Document
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/test-coverage-examples.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ name: test-coverage-examples
jobs:
test-coverage-examples:
runs-on: ubuntu-latest

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

Expand All @@ -23,9 +24,11 @@ jobs:

- uses: r-lib/actions/setup-r-dependencies@v2
with:
pak-version: devel
extra-packages: |
r-lib/covr
any::covr
local::.
needs: coverage

- name: Test example coverage
run: |
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@ jobs:

- uses: r-lib/actions/setup-r@v2
with:
http-user-agent: "release"
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
pak-version: devel
extra-packages: |
r-lib/covr
any::covr
needs: coverage

- name: Test coverage
Expand Down
6 changes: 3 additions & 3 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ references:
abstract: 'effectsize: Indices of Effect Size'
notes: Imports
url: https://easystats.github.io/effectsize/
repository: https://CRAN.R-project.org/package=effectsize
repository: https://easystats.r-universe.dev
authors:
- family-names: Ben-Shachar
given-names: Mattan S.
Expand Down Expand Up @@ -468,7 +468,7 @@ references:
given-names: Jim
- family-names: Henry
given-names: Lionel
email: lionel@rstudio.com
email: lionel@posit.co
- family-names: Müller
given-names: Kirill
email: [email protected]
Expand Down Expand Up @@ -707,7 +707,7 @@ references:
given-names: Hadley
email: [email protected]
year: '2023'
version: '>= 3.1.10'
version: '>= 3.2.0'
- type: software
title: utils
abstract: 'R: A Language and Environment for Statistical Computing'
Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Suggests:
rmarkdown,
rstantools,
survival,
testthat (>= 3.1.10),
testthat (>= 3.2.0),
utils
VignetteBuilder:
knitr
Expand Down
12 changes: 6 additions & 6 deletions R/centrality_description.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ centrality_description <- function(data,
tr = 0.2,
k = 2L,
...) {
type <- stats_type_switch(type)

# styler: off
centrality <- case_when(
type == "parametric" ~ "mean",
type == "nonparametric" ~ "median",
type == "robust" ~ "trimmed",
type == "bayes" ~ "MAP"
centrality <- case_match(
stats_type_switch(type),
"parametric" ~ "mean",
"nonparametric" ~ "median",
"robust" ~ "trimmed",
"bayes" ~ "MAP"
)
# styler: on

Expand Down
4 changes: 2 additions & 2 deletions R/one_sample_test.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ one_sample_test <- function(data,
tidy_model_parameters() %>%
select(-matches("^est|^conf|^diff|^term|^ci"))

effsize_df <- exec(
ez_df <- exec(
.f.es,
x = x_vec,
mu = test.value,
Expand All @@ -76,7 +76,7 @@ one_sample_test <- function(data,
) %>%
tidy_model_effectsize()

stats_df <- bind_cols(stats_df, effsize_df)
stats_df <- bind_cols(stats_df, ez_df)
}

# robust ---------------------------------------
Expand Down
8 changes: 4 additions & 4 deletions R/oneway_anova.R
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ oneway_anova <- function(data,

stats_df <- tidy_model_parameters(exec(.f, !!!.f.args, data = data))

effsize_df <- exec(
ez_df <- exec(
.fn = .f.es,
data = data,
ci = conf.level,
Expand All @@ -213,7 +213,7 @@ oneway_anova <- function(data,
) %>%
tidy_model_effectsize()

stats_df <- bind_cols(stats_df, effsize_df)
stats_df <- bind_cols(stats_df, ez_df)
}

# robust ---------------------------------------
Expand Down Expand Up @@ -243,11 +243,11 @@ oneway_anova <- function(data,
stats_df <- tidy_model_parameters(mod)

if (paired) {
effsize_df <- long_to_wide_converter(data, {{ x }}, {{ y }}) %>%
ez_df <- long_to_wide_converter(data, {{ x }}, {{ y }}) %>%
WRS2::wmcpAKP(select(-.rowid), tr = tr, nboot = nboot) %>%
tidy_model_parameters()

stats_df <- bind_cols(stats_df, effsize_df)
stats_df <- bind_cols(stats_df, ez_df)
}
}

Expand Down
4 changes: 2 additions & 2 deletions R/pairwise_comparisons.R
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ pairwise_comparisons <- function(data,
mutate(
expression = case_when(
p.adjust.method == "None" ~ glue("list(italic(p)[unadj.]=='{format_value(p.value, k)}')"),
TRUE ~ glue("list(italic(p)['{p.adjust.method}'-adj.]=='{format_value(p.value, k)}')")
.default = glue("list(italic(p)['{p.adjust.method}'-adj.]=='{format_value(p.value, k)}')")
)
)
}
Expand Down Expand Up @@ -296,6 +296,6 @@ p_adjust_text <- function(p.adjust.method) {
),
grepl("^BH|^f", p.adjust.method) ~ "FDR",
grepl("^BY", p.adjust.method) ~ "BY",
TRUE ~ "Holm"
.default = "Holm"
)
}
4 changes: 2 additions & 2 deletions R/tidy_model_expressions.R
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ tidy_model_expressions <- function(data,
df %<>% mutate(
expression = case_when(
df.error %in% c("NA", "Inf") ~ glue("list({es.text}=='{estimate}', italic(t)=='{statistic}', italic(p)=='{p.value}')"),
TRUE ~ glue("list({es.text}=='{estimate}', italic(t)('{df.error}')=='{statistic}', italic(p)=='{p.value}')")
.default = glue("list({es.text}=='{estimate}', italic(t)('{df.error}')=='{statistic}', italic(p)=='{p.value}')")
)
)
}
Expand Down Expand Up @@ -105,7 +105,7 @@ tidy_model_expressions <- function(data,
ungroup() %>% # convert from `expression` to `language`
mutate(expression = case_when(
is.na(unlist(expression)) ~ list(NULL),
TRUE ~ unlist(expression)
.default = unlist(expression)
)) %>%
.add_package_class()
}
Expand Down
Loading

0 comments on commit eea191f

Please sign in to comment.