Skip to content

Commit

Permalink
fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed May 26, 2024
1 parent 6fef450 commit 293880e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
4 changes: 3 additions & 1 deletion R/cor_test.R
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@
#' if (require("lme4", quietly = TRUE)) {
#' cor_test(iris, "Sepal.Length", "Sepal.Width", multilevel = TRUE)
#' }
#' cor_test(iris, "Sepal.Length", "Sepal.Width", partial_bayesian = TRUE)
#' if (require("rstanarm", quietly = TRUE)) {
#' cor_test(iris, "Sepal.Length", "Sepal.Width", partial_bayesian = TRUE)
#' }
#' }
#' @export
cor_test <- function(data,

Check warning on line 123 in R/cor_test.R

View workflow job for this annotation

GitHub Actions / lint / lint

file=R/cor_test.R,line=123,col=1,[cyclocomp_linter] Reduce the cyclomatic complexity of this function from 52 to at most 40.

Check warning on line 123 in R/cor_test.R

View workflow job for this annotation

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

file=R/cor_test.R,line=123,col=1,[cyclocomp_linter] Reduce the cyclomatic complexity of this function from 52 to at most 40.
Expand Down
4 changes: 3 additions & 1 deletion man/cor_test.Rd

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

8 changes: 4 additions & 4 deletions tests/testthat/test-cor_test.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ test_that("cor_test bayesian", {

df <- iris
df$Petal.Length2 <- df$Petal.Length
out3 <- cor_test(df, "Petal.Length", "Petal.Length2", bayesian = TRUE)
out3 <- suppressWarnings(cor_test(df, "Petal.Length", "Petal.Length2", bayesian = TRUE))
expect_equal(out3$rho, 1.000, tolerance = 0.01)

if (getRversion() >= "3.6") {
Expand Down Expand Up @@ -60,8 +60,8 @@ test_that("cor_test tetrachoric", {
skip_if_not_or_load_if_installed("psych")
skip_if_not_or_load_if_installed("polycor")
data <- iris
data$Sepal.Width_binary <- ifelse(data$Sepal.Width > 3, 1, 0)
data$Petal.Width_binary <- ifelse(data$Petal.Width > 1.2, 1, 0)
data$Sepal.Width_binary <- as.numeric(data$Sepal.Width > 3)
data$Petal.Width_binary <- as.numeric(data$Petal.Width > 1.2)

# With Factors / Binary
out <- cor_test(data, "Sepal.Width_binary", "Petal.Width_binary", method = "tetrachoric")
Expand Down Expand Up @@ -184,6 +184,6 @@ test_that("cor_test one-sided p value", {
# Edge cases --------------------------------------------------------------

test_that("cor_test 2 valid observations", {
out <- correlation(data.frame(v2 = c(2, 1, 1, 2), v3 = c(1, 2, NA, NA)))
out <- suppressWarnings(correlation(data.frame(v2 = c(2, 1, 1, 2), v3 = c(1, 2, NA, NA))))
expect_true(is.na(out$r))
})

0 comments on commit 293880e

Please sign in to comment.