Skip to content

Commit

Permalink
update after long pause
Browse files Browse the repository at this point in the history
  • Loading branch information
matcasti committed Jul 23, 2024
1 parent e99ccf3 commit 8ec1c8d
Show file tree
Hide file tree
Showing 50 changed files with 1,109 additions and 1,869 deletions.
Binary file added .DS_Store
Binary file not shown.
37 changes: 24 additions & 13 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Workflow derived from https://github.com/r-lib/actions/tree/master/examples
# 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
#
# NOTE: This workflow is overkill for most R packages and
Expand All @@ -12,6 +12,8 @@ on:

name: R-CMD-check

permissions: read-all

jobs:
R-CMD-check:
runs-on: ${{ matrix.config.os }}
Expand All @@ -22,31 +24,40 @@ jobs:
fail-fast: false
matrix:
config:
- {os: macOS-latest, r: 'release'}
- {os: macos-latest, r: 'release'}

- {os: windows-latest, r: 'release'}
# Use older ubuntu to maximise backward compatibility
- {os: ubuntu-18.04, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-18.04, r: 'release'}
- {os: ubuntu-18.04, r: 'oldrel-1'}
- {os: ubuntu-18.04, r: 'oldrel-2'}
# use 4.1 to check with rtools40's older compiler
- {os: windows-latest, r: '4.1'}

- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel-1'}
- {os: ubuntu-latest, r: 'oldrel-2'}
- {os: ubuntu-latest, r: 'oldrel-3'}
- {os: ubuntu-latest, r: 'oldrel-4'}

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

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

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

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

- uses: r-lib/actions/setup-r-dependencies@v1
- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: rcmdcheck
extra-packages: any::rcmdcheck
needs: check

- uses: r-lib/actions/check-r-package@v1
- uses: r-lib/actions/check-r-package@v2
with:
upload-snapshots: true
build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")'
58 changes: 0 additions & 58 deletions .github/workflows/check-full.yaml

This file was deleted.

6 changes: 4 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,17 @@ License: GPL (>= 3)
Encoding: UTF-8
ByteCompile: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.1.2
RoxygenNote: 7.3.1
Depends:
R (>= 3.5.0)
Imports:
data.table (>= 1.14.0),
glue (>= 1.4.2),
nortest (>= 1.0-4),
effectsize (>= 0.4.5),
afex (>= 0.28-1),
PMCMRplus (>= 1.9.0),
WRS2 (>= 1.1-1),
lifecycle
Suggests:
testthat (>= 3.0.0)
Config/testthat/edition: 3
45 changes: 3 additions & 42 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
S3method(as.data.frame,writR)
S3method(print,writR)
export(aov_r)
export(autest)
export(cent_disp)
export(clean_data)
export(contingency)
Expand All @@ -14,24 +13,18 @@ export(lablr)
export(one_sample)
export(pairs_two_sample)
export(pairwise_test)
export(rm_anova)
export(sphericity)
export(sphericity_check)
export(style.p)
export(two_sample)
importFrom(PMCMRplus,durbinAllPairsTest)
importFrom(PMCMRplus,gamesHowellTest)
importFrom(PMCMRplus,kwAllPairsDunnTest)
importFrom(WRS2,dep.effect)
importFrom(WRS2,lincon)
importFrom(WRS2,rmanova)
importFrom(WRS2,rmmcp)
importFrom(WRS2,t1way)
importFrom(WRS2,trimse)
importFrom(WRS2,wmcpAKP)
importFrom(WRS2,yuen)
importFrom(WRS2,yuen.effect.ci)
importFrom(WRS2,yuend)
importFrom(afex,aov_ez)
importFrom(data.table,"%chin%")
importFrom(data.table,"%like%")
importFrom(data.table,":=")
importFrom(data.table,.N)
importFrom(data.table,.SD)
Expand All @@ -42,40 +35,8 @@ importFrom(data.table,fcase)
importFrom(data.table,fifelse)
importFrom(data.table,melt)
importFrom(data.table,rbindlist)
importFrom(data.table,rowidv)
importFrom(data.table,setnames)
importFrom(effectsize,cohens_d)
importFrom(effectsize,cohens_g)
importFrom(effectsize,cramers_v)
importFrom(effectsize,eta_squared)
importFrom(effectsize,hedges_g)
importFrom(effectsize,kendalls_w)
importFrom(effectsize,oddsratio)
importFrom(effectsize,omega_squared)
importFrom(effectsize,pearsons_c)
importFrom(effectsize,rank_biserial)
importFrom(effectsize,rank_epsilon_squared)
importFrom(glue,glue)
importFrom(lifecycle,deprecated)
importFrom(nortest,lillie.test)
importFrom(stats,IQR)
importFrom(stats,anova)
importFrom(stats,as.formula)
importFrom(stats,chisq.test)
importFrom(stats,complete.cases)
importFrom(stats,fisher.test)
importFrom(stats,friedman.test)
importFrom(stats,kruskal.test)
importFrom(stats,lm)
importFrom(stats,mcnemar.test)
importFrom(stats,median)
importFrom(stats,na.omit)
importFrom(stats,oneway.test)
importFrom(stats,p.adjust)
importFrom(stats,pairwise.t.test)
importFrom(stats,pchisq)
importFrom(stats,sd)
importFrom(stats,shapiro.test)
importFrom(stats,t.test)
importFrom(stats,wilcox.test)
importFrom(utils,combn)
59 changes: 29 additions & 30 deletions R/aov_r.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,48 +11,47 @@
#' @param effsize.type The effect size used to estimate the effects of the factors on the response variable. Possible values are "eta" ("biased") or "omega" ("unbiased", the default).
#' @param sphericity If "none", then sphericity assumption is assumed to be met for within-subject(s) factor(s). "GG": applies Greenhouse-Geisser correction. "HF": applies Hyunh-Feldt correction. 'auto' (Default) choose the appropiate correction based on Mauchly test of sphericity (p-value > 0.05)
#' @param conf.level Confidence/Credible Interval (CI) level. Default to 0.95 (95%).
#' @param lbl Logical (default FALSE) indicating if a report ready output is desired. This will change the output to a list with characters rather than numeric vectors.
#' @param markdown Logical (default FALSE). If `lbl` is TRUE, then this argument specify if the report-ready labels should be formated for inline code for R markdown (using mathjax and markdown syntax), or if the output should be in plain text (the default).
#' @importFrom data.table %chin% as.data.table .SD fcase .N
#' @importFrom utils combn
#' @importFrom stats anova
#' @importFrom effectsize eta_squared omega_squared
#' @param character.only Logical. checks whether to use the unevaluated expression or its
#' content (when TRUE), asumming is a character vector. Defaults to `FALSE`.
#' @return A list with statistical results.
#'
#' @export

aov_r <- function(data,
response = NULL,
response,
between = NULL,
within = NULL,
rowid = NULL,
ss_type = 3,
effsize.type = "unbiased",
sphericity = "auto",
conf.level = 0.95,
lbl = if (is.null(markdown)) FALSE else TRUE,
markdown = NULL) {
character.only = FALSE,
markdown) {

`Pr(>F)` <- rn <- `num Df` <- `den Df` <- NULL

# Auxiliary functions
is_empty <- function(i) length(i) == 0;
is_not_empty <- function(i) length(i) > 0;
is_not_null <- function(i) !is.null(i);

# Argument checking
if (is.null(between) && is.null(within)) stop("between and within can't both be NULL", call. = FALSE)
if (is.null(response)) stop("response can't be NULL", call. = FALSE)
if (is_not_empty(within) && is.null(rowid)) stop("If within is provided, rowid can't be NULL", call. = FALSE)
# Argument checking - Response
if (missing(response)) stop("response can't be NULL", call. = FALSE)

# Transform data to data.table
if (!"data.table" %chin% class(data)) {
data <- data.table::as.data.table(data)
}
if (!"data.table" %chin% class(data)) data <- data.table::as.data.table(data)

# Transform arguments to character
response <- deparser(response, character.only)
between <- deparser(between, character.only)
within <- deparser(within, character.only)
rowid <- deparser(rowid, character.only)

# Argument checking - arguments
if (is.null(between) && is.null(within)) stop("between and within can't both be NULL", call. = FALSE)
if (!is.null(within) && is.null(rowid)) stop("if within is provided, rowid can't be NULL", call. = FALSE)

# Get only variables of interest
data <- droplevels(data[j = .SD, .SDcols = c(rowid, response, between, within)])
data <- droplevels(data[, .SD, .SDcols = c(rowid, response, between, within)])

if (is_empty(within) && is.null(rowid) && is_not_empty(between)) {
if (length(within) == 0 && is.null(rowid) && length(between) > 0) {
rowid <- "rowid"
data[, rowid := seq_len(.N)]
}
Expand All @@ -75,7 +74,7 @@ aov_r <- function(data,
n_obs <- nrow(model$data$wide)

# Get sphericity correction
if (is_empty(within)) {
if (length(within) == 0) {
sphericity <- NULL
} else {
sphericity <- sphericity_check(model)
Expand All @@ -100,11 +99,11 @@ aov_r <- function(data,

# Set sphericity correction (if available)
within_method <- NA_character_
if (is_not_null(within)) {
if (!is.null(within)) {
within_method <- data.table::fcase(
sphericity == "none", "Fisher's repeated measures ANOVA",
sphericity == "GG", "Repeated measures ANOVA with GG correction",
sphericity == "HF", "Repeated measures ANOVA with HG correction"
sphericity == "none", "Fisher's rmANOVA",
sphericity == "GG", "Greenhouse-Geisser's rmANOVA",
sphericity == "HF", "Huynh-Feldt's rmANOVA"
)
}

Expand All @@ -116,8 +115,8 @@ aov_r <- function(data,
df.error = `den Df`,
p.value = `Pr(>F)`,
method = data.table::fcase(rn %chin% between, "Fisher's ANOVA",
rn %chin% within, within_method,
utils::combn(within, 1, grepl, T, rn), within_method),
rn %chin% within, within_method,
utils::combn(within, 1, grepl, T, rn), within_method),
estimate = efs[[2L]],
conf.level = efs$CI,
conf.low = efs$CI_low,
Expand All @@ -126,7 +125,7 @@ aov_r <- function(data,
n_obs = n_obs
)]

if (lbl) {
if (!missing(markdown) && isTRUE(markdown)) {
model <- model[j = lablr(.SD, markdown = markdown), by = "x"]
}

Expand Down
Loading

0 comments on commit 8ec1c8d

Please sign in to comment.