R/cor_tables.R
report_cor_table.Rd
This function, creates (and optionally saves) a correlation table with summary statistics. It accepts correlation matrices from various functions in this package as its first argument
Based on the apaTables apa.cor.table()
function, but adapted to
accept weighted correlation matrices and work with the gt
package instead. Code
for calculation of confidence intervals adapted from
https://medium.com/@shandou/how-to-compute-confidence-interval-for-pearsons-r-a-brief-guide-951445b9cb2d`
A correlation matrix, for example returned from
cor_matrix()
, svy_cor_matrix()
, or cor_matrix_mi()
Method to create CI - default is to use any given in the cor_matrix, and otherwise to compute them using z-transformations. The simple SE method should not be used, but is provided for compatibility.
Number of observations to calculate confidence intervals - only needed if cor_matrix does not contain degrees of freedom (df) or numbers of observations (n) and confidence intervals are to be calculated using z-transformations
Add graphs showing variable distributions?
Original data, only needed if add_distribution = TRUE
the file name to create on disk. Include '.html' extension to best preserve formatting (see gt::gtsave for details)
List of additional notes to show under the table.
A character vector to change the significance symbols (see details below)
Should title be added to table? Set to TRUE for default title or to character for custom title
Tibble of additional columns to be added after the descriptives column -
needs to be sorted in the same order as the desc
element in the cor_matrix unless
there is a row_names
column. If there is, this will be used to match it to the desc
rows.
Logical, should APA-style formatting be applied
Arguments passed on to plot_distributions
plot_type
Type of plot that should be produced - histogram
or density
plot. If auto
,
histograms are produced for variables that take fewer than 10 unique values, density plots for others. If a number is provided,
that number is used as the maximum number of unique values for which a histogram is used.
hist_align_y
Should histograms use the same y-axis, so that bin heights are comparable? Defaults to FALSE
plot_theme
Additional theme_ commands to be added to each plot
A table that can be printed in the RStudio console to be shown in the
viewer. Unless it is to be post-processed with further gt
functions, it should
usually be saved by passing a filename argument.