Skip to content

Commit

Permalink
fix CRAN unicode issue (#521)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattansb authored Oct 18, 2022
1 parent 1b048ed commit fb7137d
Show file tree
Hide file tree
Showing 11 changed files with 113 additions and 113 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: effectsize
Title: Indices of Effect Size
Version: 0.8.0.0001
Version: 0.8.1
Authors@R:
c(person(given = "Mattan S.",
family = "Ben-Shachar",
Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# effectsize 0.8.0.0001
# effectsize 0.8.1

## Changes

Expand Down
91 changes: 2 additions & 89 deletions R/is_effectsize_name.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,99 +42,12 @@ get_effectsize_label <- function(x, ignore_case = TRUE, use_symbols = getOption(

# es_info -----------------------------------------------------------------


#' List of effect size names
#'
#' Can always add more info here if need be...
#'
#' @keywords internal
es_info <- matrix(
c(
## Diffs
"Cohens_d", "Cohen's d", NA, "twotail", -Inf, Inf, 0,
"Hedges_g", "Hedges' g", NA, "twotail", -Inf, Inf, 0,
"Glass_delta", "Glass' delta", "Glass' \u0394", "twotail", -Inf, Inf, 0,
"Mahalanobis_D", "Mahalanobis' D", NA, "onetail", 0, Inf, 0,

## xtab cor
"Cramers_v", "Cramer's V", NA, "onetail", 0, 1, 0,
"Cramers_v_adjusted", "Cramer's V (adj.)", NA, "onetail", 0, 1, 0,
"Tschuprows_t", "Tschuprow's T", NA, "onetail", 0, 1, 0,
"phi", "Phi", "\u03D5", "onetail", 0, 1, 0,
"phi_adjusted", "Phi (adj.)", "\u03D5 (adj.)", "onetail", 0, 1, 0,
"Pearsons_c", "Pearson's C", NA, "onetail", 0, 1, 0,
"Cohens_w", "Cohen's w", NA, "onetail", 0, Inf, 0,
"Fei", "Fei", "\u05E4\u200E", "onetail", 0, 1, 0,

## xtab 2x2
"Cohens_h", "Cohen's h", NA, "twotail", -pi, pi, 0,
"Odds_ratio", "Odds ratio", NA, "twotail", 0, Inf, 1,
"log_Odds_ratio", "log(Odds ratio)", NA, "twotail", -Inf, Inf, 0,
"Risk_ratio", "Risk ratio", NA, "twotail", 0, Inf, 1,
"log_Risk_ratio", "log(Risk ratio)", NA, "twotail", -Inf, Inf, 0,

## xtab dep
"Cohens_g", "Cohen's g", NA, "onetail", -0.5, 0.5, 0,

## ANOVA
"Eta2", "Eta2", "\u03B7\u00b2", "onetail", 0, 1, 0,
"Eta2_partial", "Eta2 (partial)", "\u03B7\u00b2 (partial)", "onetail", 0, 1, 0,
"Eta2_generalized", "Eta2 (generalized)", "\u03B7\u00b2 (generalized)", "onetail", 0, 1, 0,
"Epsilon2", "Epsilon2", "\u03B5\u00b2", "onetail", 0, 1, 0,
"Epsilon2_partial", "Epsilon2 (partial)", "\u03B5\u00b2 (partial)", "onetail", 0, 1, 0,
"Omega2", "Omega2", "\u03C9\u00b2", "onetail", 0, 1, 0,
"Omega2_partial", "Omega2 (partial)", "\u03C9\u00b2 (partial)", "onetail", 0, 1, 0,
"Cohens_f", "Cohen's f", NA, "onetail", 0, Inf, 0,
"Cohens_f_partial", "Cohen's f (partial)", NA, "onetail", 0, Inf, 0,
"Cohens_f2", "Cohen's f2", "Cohen's f\u00b2", "onetail", 0, Inf, 0,
"Cohens_f2_partial", "Cohen's f2 (partial)", "Cohen's f\u00b2 (partial)", "onetail", 0, Inf, 0,

## Rank
"r_rank_biserial", "r (rank biserial)", NA, "twotail", -1, 1, 0,
"Kendalls_W", "Kendall's W", NA, "onetail", 0, 1, 0,
"rank_epsilon_squared", "Epsilon2 (rank)", "\u03B5\u00b2(R)", "onetail", 0, 1, 0,
"rank_eta_squared", "Eta2 (rank)", "\u03B7\u00b2(H)", "onetail", 0, 1, 0,

## CLES
"p_superiority", "Pr(superiority)", NA, "twotail", 0, 1, 0.5,
"WMW_odds", "WMW Odds", NA, "twotail", 0, Inf, 1,
"Cohens_U1", "Cohen's U1", NA, "onetail", 0, 1, 0,
"Cohens_U2", "Cohen's U2", NA, "onetail", 0.5, 1, 0.5,
"Cohens_U3", "Cohen's U3", NA, "twotail", 0, 1, 0.5,
"overlap", "Overlap", NA, "onetail", 0, 1, 1,

## Other
"r", "r", NA, "twotail", -1, 1, 0,
"d", "d", NA, "twotail", -Inf, Inf, 0,

## Std Coefficient
"Std_Coefficient", "Coefficient (std.)", NA, "twotail", -Inf, Inf, 0,
"Std_Odds_ratio", "Odds Ratio (std.)", NA, "twotail", 0, Inf, 1,
"Std_Risk_ratio", "Risk Ratio (std.)", NA, "twotail", 0, Inf, 1,
"Std_IRR", "IRR (std.)", "twotail", NA, 0, Inf, 1,
"Std_Median", "Median (std.)", NA, "twotail", -Inf, Inf, 0,
"Std_Mean", "Mean (std.)", NA, "twotail", -Inf, Inf, 0,
"Std_MAP", "MAP (std.)", NA, "twotail", -Inf, Inf, 0
),
ncol = 7, byrow = TRUE,
dimnames = list(NULL, c("name", "label", "symbol", "direction", "lb", "ub", "null"))
)
es_info <- as.data.frame(es_info, stringsAsFactors = FALSE)
es_info$lb <- as.numeric(es_info$lb)
es_info$ub <- as.numeric(es_info$ub)
es_info$null <- as.numeric(es_info$null)
es_info$symbol[is.na(es_info$symbol)] <- es_info$label[is.na(es_info$symbol)]
rownames(es_info) <- es_info$name

# See data-raw/es_info.R

# Utils -------------------------------------------------------------------


#' @keywords internal
.resolve_use_symbols <- function(use_symbols) {
use_symbols &&
!(
(Sys.info()["sysname"] == "windows" || grepl("^mingw", R.version$os)) &&
getRversion() < "4.2"
)
use_symbols && l10n_info()[["UTF-8"]]
}
Binary file added R/sysdata.rda
Binary file not shown.
18 changes: 18 additions & 0 deletions WIP/convert_stat_H.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#' Convert H statistic to Rank Epsilon / Eta Squared
#'
#' @param H Kruskal-Wallis rank sum test statistic. See [stats::kruskal.test()]
#' @param N Total sample size
#' @param k Number of groups
#'
#' @export
h_to_epsilon <- function(H, N) {
H / ((N^2 - 1) / (N + 1))
}

#' @export
#' @rdname h_to_epsilon
h_to_epsilon <- function(H, N, k) {
(H - k + 1) / (N - k)
}

# TODO use these internally
73 changes: 73 additions & 0 deletions data-raw/es_info.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
es_info <- tibble::tribble(
~name, ~label, ~symbol, ~direction, ~lb, ~ub, ~null,
## Std. diffs
"Cohens_d", "Cohen's d", NA, "twotail", -Inf, Inf, 0,
"Hedges_g", "Hedges' g", NA, "twotail", -Inf, Inf, 0,
"Glass_delta", "Glass' delta", "Glass' \u0394", "twotail", -Inf, Inf, 0,
"Mahalanobis_D", "Mahalanobis' D", NA, "onetail", 0, Inf, 0,

## xtab cor
"Cramers_v", "Cramer's V", NA, "onetail", 0, 1, 0,
"Cramers_v_adjusted", "Cramer's V (adj.)", NA, "onetail", 0, 1, 0,
"Tschuprows_t", "Tschuprow's T", NA, "onetail", 0, 1, 0,
"phi", "Phi", "\u03D5", "onetail", 0, 1, 0,
"phi_adjusted", "Phi (adj.)", "\u03D5 (adj.)", "onetail", 0, 1, 0,
"Pearsons_c", "Pearson's C", NA, "onetail", 0, 1, 0,
"Cohens_w", "Cohen's w", NA, "onetail", 0, Inf, 0,
"Fei", "Fei", "\u05E4\u200E", "onetail", 0, 1, 0,

## xtab 2x2
"Cohens_h", "Cohen's h", NA, "twotail", -pi, pi, 0,
"Odds_ratio", "Odds ratio", NA, "twotail", 0, Inf, 1,
"log_Odds_ratio", "log(Odds ratio)", NA, "twotail", -Inf, Inf, 0,
"Risk_ratio", "Risk ratio", NA, "twotail", 0, Inf, 1,
"log_Risk_ratio", "log(Risk ratio)", NA, "twotail", -Inf, Inf, 0,

## xtab dep
"Cohens_g", "Cohen's g", NA, "onetail", -0.5, 0.5, 0,

## ANOVA
"Eta2", "Eta2", "\u03B7\u00b2", "onetail", 0, 1, 0,
"Eta2_partial", "Eta2 (partial)", "\u03B7\u00b2 (partial)", "onetail", 0, 1, 0,
"Eta2_generalized", "Eta2 (generalized)", "\u03B7\u00b2 (generalized)", "onetail", 0, 1, 0,
"Epsilon2", "Epsilon2", "\u03B5\u00b2", "onetail", 0, 1, 0,
"Epsilon2_partial", "Epsilon2 (partial)", "\u03B5\u00b2 (partial)", "onetail", 0, 1, 0,
"Omega2", "Omega2", "\u03C9\u00b2", "onetail", 0, 1, 0,
"Omega2_partial", "Omega2 (partial)", "\u03C9\u00b2 (partial)", "onetail", 0, 1, 0,
"Cohens_f", "Cohen's f", NA, "onetail", 0, Inf, 0,
"Cohens_f_partial", "Cohen's f (partial)", NA, "onetail", 0, Inf, 0,
"Cohens_f2", "Cohen's f2", "Cohen's f\u00b2", "onetail", 0, Inf, 0,
"Cohens_f2_partial", "Cohen's f2 (partial)", "Cohen's f\u00b2 (partial)", "onetail", 0, Inf, 0,

## Rank
"r_rank_biserial", "r (rank biserial)", NA, "twotail", -1, 1, 0,
"Kendalls_W", "Kendall's W", NA, "onetail", 0, 1, 0,
"rank_epsilon_squared", "Epsilon2 (rank)", "\u03B5\u00b2(R)", "onetail", 0, 1, 0,
"rank_eta_squared", "Eta2 (rank)", "\u03B7\u00b2(H)", "onetail", 0, 1, 0,

## CLES
"p_superiority", "Pr(superiority)", NA, "twotail", 0, 1, 0.5,
"WMW_odds", "WMW Odds", NA, "twotail", 0, Inf, 1,
"Cohens_U1", "Cohen's U1", NA, "onetail", 0, 1, 0,
"Cohens_U2", "Cohen's U2", NA, "onetail", 0.5, 1, 0.5,
"Cohens_U3", "Cohen's U3", NA, "twotail", 0, 1, 0.5,
"overlap", "Overlap", NA, "onetail", 0, 1, 1,

## Other
"r", "r", NA, "twotail", -1, 1, 0,
"d", "d", NA, "twotail", -Inf, Inf, 0,

## Std Coefficient
"Std_Coefficient", "Coefficient (std.)", NA, "twotail", -Inf, Inf, 0,
"Std_Odds_ratio", "Odds Ratio (std.)", NA, "twotail", 0, Inf, 1,
"Std_Risk_ratio", "Risk Ratio (std.)", NA, "twotail", 0, Inf, 1,
"Std_IRR", "IRR (std.)", "twotail", NA, 0, Inf, 1,
"Std_Median", "Median (std.)", NA, "twotail", -Inf, Inf, 0,
"Std_Mean", "Mean (std.)", NA, "twotail", -Inf, Inf, 0,
"Std_MAP", "MAP (std.)", NA, "twotail", -Inf, Inf, 0
)

es_info <- as.data.frame(es_info)
es_info[is.na(es_info[["symbol"]]), "symbol"] <- es_info[is.na(es_info[["symbol"]]), "label"]
rownames(es_info) <- es_info[["name"]]
usethis::use_data(es_info, internal = TRUE)
5 changes: 5 additions & 0 deletions dev/rhub.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
library(rhub)

# validate_email()
# list_validated_emails()
check(platforms = "debian-clang-devel")
16 changes: 0 additions & 16 deletions man/es_info.Rd

This file was deleted.

5 changes: 4 additions & 1 deletion tests/testthat/test-eta_squared.R
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,10 @@ test_that("afex | mixed()", {

data(md_15.1, package = "afex")
# random intercept plus random slope
t15.4a <- afex::mixed(iq ~ timecat + (1 + time | id), data = md_15.1)
t15.4a <- afex::mixed(iq ~ timecat + (1 + time | id),
data = md_15.1,
method = "S"
)
expect_equal(
eta_squared(t15.4a),
eta_squared(t15.4a$full_model)
Expand Down
5 changes: 2 additions & 3 deletions tests/testthat/test-print.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# library(testthat)

test_that("print | effectsize table", {
## digits
Expand Down Expand Up @@ -168,9 +169,7 @@ test_that("rules", {


test_that("printing symbols works as expected", {
skip_if(getRversion() < 4.2 &&
(Sys.info()["sysname"] == "windows" ||
grepl("^mingw", R.version$os)))
skip_if_not(l10n_info()[["UTF-8"]])

RCT <- matrix(c(71, 50, 30, 100), nrow = 2L)
P <- phi(RCT)
Expand Down
9 changes: 7 additions & 2 deletions vignettes/anovaES.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,12 @@ always the case.

For example, in linear mixed models (LMM/HLM/MLM), the estimation of all required *SS*s is not straightforward. However, we can still *approximate* these effect sizes (only their partial versions) based on the **test-statistic approximation method** (learn more in the [*Effect Size from Test Statistics* vignette](https://easystats.github.io/effectsize/articles/from_test_statistics.html)).

```{r, eval=require(lmerTest)}
```{r, echo = FALSE, eval=TRUE}
lmm_pkgs <- c("lmerTest", "lme4")
eval_lmm <- all(sapply(lmm_pkgs, requireNamespace, quietly = TRUE))
```

```{r, eval=eval_lmm}
library(lmerTest)
fit_lmm <- lmer(Reaction ~ Days + (Days | Subject), sleepstudy)
Expand All @@ -246,7 +251,7 @@ F_to_eta2(45.8, df = 1, df_error = 17)
Or directly with `eta_squared() and co.:


```{r, eval=require(lmerTest)}
```{r, eval=eval_lmm}
eta_squared(fit_lmm)
epsilon_squared(fit_lmm)
omega_squared(fit_lmm)
Expand Down

0 comments on commit fb7137d

Please sign in to comment.