The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

Title: Creates and Saves Out a Correlation Table with Significance Levels Indicated
Version: 0.1.1
Description: After using this, a publication-ready correlation table with p-values indicated will be created. The input can be a full data frame; any string and Boolean terms will be dropped as part of functionality. Correlations and p-values are calculated using the 'Hmisc' framework. Output of the correlation_matrix() function is a table of strings; this gets saved out to a '.csv2' with the save_correlation_matrix() function for easy insertion into a paper. For more details about the process, consult https://paulvanderlaken.com/2020/07/28/publication-ready-correlation-matrix-significance-r/.
License: GPL-3
Encoding: UTF-8
RoxygenNote: 7.2.1
Imports: Hmisc
Suggests: waldo, withr, testthat (≥ 3.0.0)
Config/testthat/edition: 3
NeedsCompilation: no
Packaged: 2023-11-02 18:08:40 UTC; laycocla
Author: Paul van der Laken ORCID iD [aut], Laura Lambert ORCID iD [ctb, cre]
Maintainer: Laura Lambert <laura.lambert.99@gmail.com>
Repository: CRAN
Date/Publication: 2023-11-02 19:30:02 UTC

Creates a publication-ready / formatted correlation matrix, using Hmisc::rcorr in the backend.

Description

Creates a publication-ready / formatted correlation matrix, using Hmisc::rcorr in the backend.

Usage

correlation_matrix(
  df,
  type = "pearson",
  digits = 3,
  decimal.mark = ".",
  use = "all",
  show_significance = TRUE,
  replace_diagonal = FALSE,
  replacement = ""
)

Arguments

df

dataframe; containing numeric and/or logical columns to calculate correlations for

type

character; specifies the type of correlations to compute; gets passed to Hmisc::rcorr; options are "pearson" or "spearman"; defaults to "pearson"

digits

integer/double; number of decimals to show in the correlation matrix; gets passed to formatC; defaults to 3

decimal.mark

character; which decimal.mark to use; gets passed to formatC; defaults to .

use

character; which part of the correlation matrix to display; options are "all", "upper", "lower"; defaults to "all"

show_significance

boolean; whether to add * to represent the significance levels for the correlations; defaults to TRUE

replace_diagonal

boolean; whether to replace the correlations on the diagonal; defaults to FALSE

replacement

character; what to replace the diagonal and/or upper/lower triangles with; defaults to "" (empty string)

Value

a correlation matrix

Examples

correlation_matrix(iris)
correlation_matrix(mtcars)

Creates and save to file a fully formatted correlation matrix, using correlation_matrix and Hmisc::rcorr in the backend

Description

Creates and save to file a fully formatted correlation matrix, using correlation_matrix and Hmisc::rcorr in the backend

Usage

save_correlation_matrix(df, filename, ...)

Arguments

df

dataframe; passed to correlation_matrix

filename

either a character string naming a file or a connection open for writing. "" indicates output to the console; passed to write.csv

...

any other arguments passed to correlation_matrix

Value

'csv' file. No value is returned.

Examples


save_correlation_matrix(df = iris,
                        filename = 'iris-correlation-matrix.csv')

save_correlation_matrix(df = mtcars,
                        filename = 'mtcars-correlation-matrix.csv',
                        digits = 3,
                        use = 'lower')
                        

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.