Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] cor_diff() : test for differences between correlations #338

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions R/cor_diff.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
cor_diff <- function(data, x, y, x2 = NULL, y2 = NULL, method = "parametric", ...) {

# If pairs are passed
if(length(x) == 2 & length(y) == 2) {
if(length(x) == 2 && length(y) == 2) {

Check warning on line 31 in R/cor_diff.R

View workflow job for this annotation

GitHub Actions / lint / lint

file=R/cor_diff.R,line=31,col=5,[spaces_left_parentheses_linter] Place a space before left parenthesis, except in a function call.

Check warning on line 31 in R/cor_diff.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/cor_diff.R,line=31,col=5,[spaces_left_parentheses_linter] Place a space before left parenthesis, except in a function call.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

space_around

x2 <- y[1]
y2 <- y[2]
y <- x[2]
Expand All @@ -36,7 +36,7 @@
}

# Compute
if(method %in% c("bootstrapping")) {

Check warning on line 39 in R/cor_diff.R

View workflow job for this annotation

GitHub Actions / lint / lint

file=R/cor_diff.R,line=39,col=5,[spaces_left_parentheses_linter] Place a space before left parenthesis, except in a function call.

Check warning on line 39 in R/cor_diff.R

View workflow job for this annotation

GitHub Actions / lint / lint

file=R/cor_diff.R,line=39,col=18,[unnecessary_concatenation_linter] Remove unnecessary c() of a constant.

Check warning on line 39 in R/cor_diff.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/cor_diff.R,line=39,col=5,[spaces_left_parentheses_linter] Place a space before left parenthesis, except in a function call.

Check warning on line 39 in R/cor_diff.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/cor_diff.R,line=39,col=18,[unnecessary_concatenation_linter] Remove unnecessary c() of a constant.
out <- .cor_diff_bootstrapping(data, x, y, x2, y2, ...)
} else {
out <- .cor_diff_parametric(data, x, y, x2, y2, ...)
Expand All @@ -56,11 +56,11 @@

insight::check_if_installed("psych", "for 'parametric' correlation difference method")

args <- list(n = nrow(data), r12 = cor(data[[x]], data[[y]]))

Check warning on line 59 in R/cor_diff.R

View workflow job for this annotation

GitHub Actions / lint / lint

file=R/cor_diff.R,line=59,col=3,[object_overwrite_linter] 'args' is an exported object from package 'base'. Avoid re-using such symbols.

Check warning on line 59 in R/cor_diff.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/cor_diff.R,line=59,col=3,[object_overwrite_linter] 'args' is an exported object from package 'base'. Avoid re-using such symbols.
if(x == x2 & y != y2) {
if(x == x2 && y != y2) {

Check warning on line 60 in R/cor_diff.R

View workflow job for this annotation

GitHub Actions / lint / lint

file=R/cor_diff.R,line=60,col=5,[spaces_left_parentheses_linter] Place a space before left parenthesis, except in a function call.

Check warning on line 60 in R/cor_diff.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/cor_diff.R,line=60,col=5,[spaces_left_parentheses_linter] Place a space before left parenthesis, except in a function call.
args$r13 <- cor(data[[x]], data[[y2]])
args$r23 <- cor(data[[y]], data[[y2]])
} else if(y == y2 & x != x2) {
} else if(y == y2 && x != x2) {

Check warning on line 63 in R/cor_diff.R

View workflow job for this annotation

GitHub Actions / lint / lint

file=R/cor_diff.R,line=63,col=12,[spaces_left_parentheses_linter] Place a space before left parenthesis, except in a function call.

Check warning on line 63 in R/cor_diff.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/cor_diff.R,line=63,col=12,[spaces_left_parentheses_linter] Place a space before left parenthesis, except in a function call.
args$r13 <- cor(data[[y]], data[[x2]])
args$r23 <- cor(data[[x]], data[[x2]])
} else {
Expand All @@ -68,10 +68,10 @@
}
test <- do.call(psych::r.test, args)

out <- data.frame(

Check warning on line 71 in R/cor_diff.R

View workflow job for this annotation

GitHub Actions / lint / lint

file=R/cor_diff.R,line=71,col=10,[strings_as_factors_linter] Supply an explicit value for stringsAsFactors for this code to work before and after R version 4.0.

Check warning on line 71 in R/cor_diff.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/cor_diff.R,line=71,col=10,[strings_as_factors_linter] Supply an explicit value for stringsAsFactors for this code to work before and after R version 4.0.
Method = "parametric"
)
if("t" %in% names(test)){

Check warning on line 74 in R/cor_diff.R

View workflow job for this annotation

GitHub Actions / lint / lint

file=R/cor_diff.R,line=74,col=5,[spaces_left_parentheses_linter] Place a space before left parenthesis, except in a function call.

Check warning on line 74 in R/cor_diff.R

View workflow job for this annotation

GitHub Actions / lint / lint

file=R/cor_diff.R,line=74,col=27,[brace_linter] There should be a space before an opening curly brace.

Check warning on line 74 in R/cor_diff.R

View workflow job for this annotation

GitHub Actions / lint / lint

file=R/cor_diff.R,line=74,col=27,[paren_body_linter] Put a space between a right parenthesis and a body expression.

Check warning on line 74 in R/cor_diff.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/cor_diff.R,line=74,col=5,[spaces_left_parentheses_linter] Place a space before left parenthesis, except in a function call.

Check warning on line 74 in R/cor_diff.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/cor_diff.R,line=74,col=27,[brace_linter] There should be a space before an opening curly brace.

Check warning on line 74 in R/cor_diff.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/cor_diff.R,line=74,col=27,[paren_body_linter] Put a space between a right parenthesis and a body expression.
out$t <- test$t
} else {
out$z <- test$z
Expand Down
Loading