ctrx {Conigrave} | R Documentation |
Correlatrix
Description
Takes in a dat#'a.frame or imputationList, a vector of variable names and produces a correlation matrix with customizable significance stars.
Usage
ctrx(data, x = NULL, y = NULL, triangle = "both", round = 2,
method = "pearson", n.matrix = F, abbreviate = 100,
stars = c(0.05, 0.01, 0.001), partial = c(), describe = F,
leading.zero = T, ...)
Arguments
data |
a data.frame or imputationList. |
x |
a vector of variable names to correlate (optional). |
y |
a vector of column names for the creation of asymmetric correlation matrices. |
triangle |
a string containing one of "lower" "upper" or "both". Indicates if correlations are to be displayed above or below the diagonal. "Both" is selected by default. |
round |
a numeral indicating number of decimals. |
method |
a string containing one of "pearson","spearman" or "kendall". |
n.matrix |
logical. If TRUE, matrix of n returned. |
abbreviate |
a number indicating the maximum length of variable names. |
stars |
a numeric vector. For each numeral, a star will be assigned which indicates that the p-value for a given correlation was smaller than, that level. The default is 0.05, 0.01 and 0.001. |
partial |
a vector of colnames. If supplied the function will output a matrix of partial correlations. All effects will be controlled for by the variables in this vector. |
describe |
a list of functions with names or a logical. If functions are supplied to describe, a new column will be appended to the final data.frame for each argument in the list. If TRUE is supplied, means and standard deviation is appended with na.rm = T. |
leading.zero |
a logical. If FALSE, leading zeros are removed. |
... |
the argument 'var.names' from previous versions has been deprecated, please use x instead. |
Value
A data.frame containing a correlation matrix.
Examples
correlatrix(mtcars[,1:5])
library(dplyr)
mtcars %>%
ctrx(x = c("mpg","cyl","disp")
,y = c("wt","drat"),
round = 2,
stars = c(0.05),
describe = list("mean" = function(x) mean(x,na.rm=TRUE)))