Skip to content

Commit

Permalink
Merge pull request #284 from easystats/rc_0_8_4
Browse files Browse the repository at this point in the history
Prepare CRAN submission
  • Loading branch information
bwiernik authored Apr 5, 2023
2 parents 5532aeb + fcc0db9 commit ce57718
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 288 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: correlation
Title: Methods for Correlation Analysis
Version: 0.8.3.3
Version: 0.8.4
Authors@R:
c(person(given = "Dominique",
family = "Makowski",
Expand Down
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

- Minor improvements and code revisions due to changes in other packages.

- Default color scheme for correlation matrices switched to use red for negative
values and blue for positive values.

# correlation 0.8.3

## Breaking Changes
Expand Down
9 changes: 6 additions & 3 deletions R/cor_to_p.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
#' cor_to_ci(-0.1175698, n = 150)
#' cor_to_ci(cor(iris[1:4]), n = 150)
#'
#' cor.test(iris$Sepal.Length, iris$Sepal.Width, method = "spearman")
#' cor.test(iris$Sepal.Length, iris$Sepal.Width, method = "spearman", exact = FALSE)
#' cor_to_p(-0.1667777, n = 150, method = "spearman")
#' cor_to_ci(-0.1667777, ci = 0.95, n = 150)
#'
#' cor.test(iris$Sepal.Length, iris$Sepal.Width, method = "kendall")
#' cor.test(iris$Sepal.Length, iris$Sepal.Width, method = "kendall", exact = FALSE)
#' cor_to_p(-0.07699679, n = 150, method = "kendall")
#' @references Bishara, A. J., & Hittner, J. B. (2017). Confidence intervals for
#' correlations when data are not normal. Behavior research methods, 49(1),
Expand All @@ -30,7 +30,10 @@
cor_to_p <- function(cor, n, method = "pearson") {
# Statistic
if (method == "kendall") {
warning("Estimation for Kendall's correlation is not perfectly correct. Help us to improve it.", call. = FALSE)
insight::format_alert(
"p-value estimation for Kendall's correlation is not perfectly correct.",
"Help us to improve it."
)
statistic <- (3 * cor * sqrt(n * (n - 1))) / sqrt(2 * (2 * n + 5))
} else {
statistic <- cor * sqrt((n - 2) / (1 - cor^2))
Expand Down
4 changes: 2 additions & 2 deletions man/cor_to_p.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions tests/testthat/_snaps/as.list.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
---

Code
suppressWarnings(as.list(msleep %>% group_by(vore) %>% correlation(method = "spearman")))
as.list(correlation(datawizard::data_group(msleep, "vore"), method = "spearman"))
Output
=======
carni
Expand Down Expand Up @@ -213,8 +213,8 @@
---

Code
suppressWarnings(as.list(mtcars %>% group_by(am) %>% correlation(select = c(
"cyl", "wt"), select2 = "hp", method = "percentage")))
as.list(correlation(datawizard::data_group(mtcars, "am"), select = c("cyl",
"wt"), select2 = "hp", method = "percentage"))
Output
===
0
Expand Down
277 changes: 0 additions & 277 deletions tests/testthat/_snaps/as.list.new.md

This file was deleted.

2 changes: 1 addition & 1 deletion tests/testthat/test-cor_to_p.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
test_that("cor_to_p", {
expect_warning(df <- cor_to_p(-0.1175698, n = 150, method = "kendall"))
expect_message(df <- cor_to_p(-0.1175698, n = 150, method = "kendall"))
expect_equal(
df,
list(p = 0.0327638207025712, statistic = -2.1349655930582),
Expand Down
2 changes: 1 addition & 1 deletion vignettes/types.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ data %>%
) %>%
mutate(Type = relevel(as.factor(Type), "Pearson", "Spearman", "Kendall", "Biweight", "Distance")) %>%
ggplot(aes(x = r, y = Estimation, fill = Type)) +
geom_smooth(aes(color = Type), method = "loess", alpha = 0) +
geom_smooth(aes(color = Type), method = "loess", alpha = 0, na.rm = TRUE) +
geom_vline(aes(xintercept = 0.5), linetype = "dashed") +
geom_hline(aes(yintercept = 0.5), linetype = "dashed") +
guides(colour = guide_legend(override.aes = list(alpha = 1))) +
Expand Down

0 comments on commit ce57718

Please sign in to comment.