corp {quest} | R Documentation |
Bivariate Correlations with Significant Symbols
Description
corp
computes bivariate correlations and their associated p-values.
The function is primarily for preparing a correlation table for publication:
the correlations are appended by significant symbols (e.g., asterixis),
corp
is simply corr.test
+ add_sig_cor
.
Usage
corp(
data,
vrb.nm,
use = "pairwise.complete.obs",
method = "pearson",
digits = 3L,
p.10 = "",
p.05 = "*",
p.01 = "**",
p.001 = "***",
lead.zero = FALSE,
trail.zero = TRUE,
plus = FALSE,
diags = FALSE,
lower = TRUE,
upper = FALSE
)
Arguments
data |
data.frame of data. |
vrb.nm |
character vector of colnames from |
use |
character vector of length 1 specifying how to handle missing data
when computing the correlations. The options are 1)
"pairwise.complete.obs", 2) "complete.obs", 3) "na.or.complete", 4)
"all.obs", or 5) "everything". See details of |
method |
character vector of length 1 specifying the type of
correlations to be computed. The options are 1) "pearson", 2) "kendall", or
3) "spearman". See details of |
digits |
integer vector of length 1 specifying the number of decimals to round to. |
p.10 |
character vector of length 1 specifying which symbol to append to the end of any correlation significant at the p < .10 level. |
p.05 |
character vector of length 1 specifying which symbol to append to the end of any correlation significant at the p < .05 level. |
p.01 |
character vector of length 1 specifying which symbol to append to the end of any correlation significant at the p < .01 level. |
p.001 |
character vector of length 1 specifying which symbol to append to the end of any correlation significant at the p < .001 level. |
lead.zero |
logical vector of length 1 specifying whether to retain a zero in front of the decimal place. |
trail.zero |
logical vector of length 1 specifying whether to retain zeros after the decimal place (due to rounding). |
plus |
logical vector of length 1 specifying whether to include a plus sign in front of positive correlations (minus signs are always in front of negative correlations). |
diags |
logical vector of length 1 specifying whether to retain the
values in the diagonal of the correlation matrix. If TRUE, then the
diagonal will be 1s with |
lower |
logical vector of length 1 specifying whether to retain the lower triangle of the correlation matrix. If TRUE, then the lower triangle correlations and their significance symbols are retained. If FAlSE, then the lower triangle will all be NA. |
upper |
logical vector of length 1 specifying whether to retain the upper triangle of the correlation matrix. If TRUE, then the upper triangle correlations and their significance symbols are retained. If FAlSE, then the upper triangle will all be NA. |
Value
data.frame with rownames and colnames equal to vrb.nm
containing the bivariate correlations with significance symbols after the
correlation value, specified by the arguments p.10
, p.05
,
p.01
, and p.001
arguments. The specific elements of the
return object are determined by the other arguments.
See Also
add_sig_cor
for adding significant symbols to a correlation matrix,
add_sig
for adding significant symbols to any (atomic) vector, matrix, or (3D+) array,
cor
for computing only the correlation coefficients themselves
corr.test
for a function providing confidence intervals as well
Examples
corp(data = mtcars, vrb.nm = c("mpg","cyl","disp","hp","drat")) # no quotes b/c a data.frame
corp(data = attitude, vrb.nm = colnames(attitude))
corp(data = attitude, vrb.nm = colnames(attitude), p.10 = "'") # advance & privileges
corp(data = airquality, vrb.nm = colnames(airquality), plus = TRUE)