Takes in a dat#'a.frame or imputationList, a vector of variable names and produces a correlation matrix with customizable significance stars.
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, ...)
a data.frame or imputationList.
a vector of variable names to correlate (optional).
a vector of column names for the creation of asymmetric correlation matrices.
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.
a numeral indicating number of decimals.
a string containing one of "pearson","spearman" or "kendall".
logical. If TRUE, matrix of n returned.
a number indicating the maximum length of variable names.
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.
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.
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.
a logical. If FALSE, leading zeros are removed.
the argument 'var.names' from previous versions has been deprecated, please use x instead.
A data.frame containing a correlation matrix.
# NOT RUN {
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)))
# }
Run the code above in your browser using DataLab