Skip to content

Commit

Permalink
fix for plotting
Browse files Browse the repository at this point in the history
  • Loading branch information
DominiqueMakowski committed Sep 12, 2019
1 parent 459751c commit 96ceb17
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 6 deletions.
31 changes: 25 additions & 6 deletions R/cor_test.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ cor_test <- function(data, x, y, ci = "default", method = "pearson", bayesian =
out <- .cor_test_bayes(data, x, y, ci = ci, iterations = iterations, rope_full = rope_full, rope_bounds = rope_bounds)
}

return(out)
out
}


Expand Down Expand Up @@ -49,7 +49,7 @@ cor_test <- function(data, x, y, ci = "default", method = "pearson", bayesian =
if("S" %in% names(params)) params$S <- Inf
}

return(params)
params
}


Expand All @@ -62,9 +62,7 @@ cor_test <- function(data, x, y, ci = "default", method = "pearson", bayesian =
#' @keywords internal
.cor_test_bayes <- function(data, x, y, ci = 0.90, iterations = 10^4, rope_full = TRUE, rope_range = c(-0.05, 0.05), prior="medium", ...) {
if (!requireNamespace("BayesFactor")) {
warning("This function needs `BayesFactor` to be installed... installing now.")
install.packages("BayesFactor")
requireNamespace("BayesFactor")
stop("This function needs `BayesFactor` to be installed. Please install by running `install.packages('BayesFactor')`.")
}

var_x <- data[[x]]
Expand Down Expand Up @@ -112,5 +110,26 @@ cor_test <- function(data, x, y, ci = "default", method = "pearson", bayesian =
}


return(params)
params
}




#' #' @examples
#' #' x <- ifelse(iris$Sepal.Width > median(iris$Sepal.Width), 1, 0)
#' #' y <- ifelse(iris$Petal.Width > median(iris$Petal.Width), 1, 0)
#' #' @keywords internal
#' .cor_test_tetrachoric <- function(x, y, ci = 0.95, ...) {
#'
#' if (!requireNamespace("psych", quietly = TRUE)) {
#' stop("Package `psych` required for tetrachoric correlations. Please install it.", call. = FALSE)
#' }
#'
#' data <- data.frame(x=x, y=y)
#' rez <- psych::tetrachoric(data)
#'
#' rez$rho
#'
#' }

9 changes: 9 additions & 0 deletions R/correlation.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,20 @@
#' @importFrom dplyr enquos
#' @export
correlation <- function(data, data2 = NULL, ci = "default", method = "pearson", p_adjust = "holm", partial = FALSE, bayesian = FALSE, iterations = 10^4, rope_full = TRUE, rope_bounds = c(-0.05, 0.05), prior="medium", ...) {

# Sanity checks
if (partial == TRUE & bayesian == TRUE) {
warning("Bayesian partial correlations are not supported yet. Running frequentist analysis...")
bayesian <- FALSE
}

# CI level
if (bayesian == FALSE) {
if (ci == "default") ci <- 0.95
} else {
if (ci == "default") ci <- 0.9
}

if (inherits(data, "grouped_df")) {
groups <- dplyr::group_vars(data)
ungrouped_x <- dplyr::ungroup(data)
Expand Down
24 changes: 24 additions & 0 deletions pkgdown/extra.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/* Syntax highlighting ---------------------------------------------------- */

/*pre {*/
/* overflow: auto;*/
/* word-wrap: normal;*/
/* word-break: normal;*/
/* border: 1px solid #eee;*/
/* background-color: #455A64;*/
/*}*/



/*.fl {color: #1514b5;}*/
/*.fu {color: #FF9800;}*/ /* function */
/*.ch,.st {color: #CDDC39;}*/ /* string */
/*.kw {color: #FFC107;}*/ /* keyword */
/*.co {color: #9E9E9E;}*/ /* comment */

/*.message { color: #EEEEEE; font-weight: bolder;}*/
/*.error { color: #f44336; font-weight: bolder;}*/
/*.warning { color: #9C27B0; font-weight: bolder;}*/

.ch,.st {color: orange;} /* string */
.co {color: #BDBDBD;} /* comment */

0 comments on commit 96ceb17

Please sign in to comment.