MyNixOS website logo
Description

Correlation Arrays and 2-Sample Correlation Matrices.

The goal of 'corrarray' is to create a multi-sample correlation array by combining the correlation matrices of a data set stratified by a grouping variable. For two specified levels of the variable, 'corrarray' displays one level's correlation matrix in the lower triangular matrix and the other level's correlation matrix in the upper triangular matrix. Such an output can enable visualization of correlations from two samples in a single correlation matrix or corrgram.

corrarray

Travis buildstatus AppVeyor buildstatus

The goal of ‘corrarray’ is to create a multi-sample correlation array by combining the correlation matrices of a data set stratified by a grouping variable. For two specified levels of the variable, ‘corrarray’ displays one level’s correlation matrix in the lower triangular matrix and the other level’s in the upper triangular matrix. Such an output can enable visualization of correlations from two samples in a single correlation matrix or corrgram.

Installation

You can install the released version of ‘corrarray’ from CRAN with:

install.packages("corrarray")

Example

The following illustrates how ‘corrarray’ can be used to generate a 1- or 2-sample correlation matrix or a k-sample correlation array:

library(corrarray)
## All observations: 1-sample correlation matrix.
corrarray(iris)
#>              Sepal.Length Sepal.Width Petal.Length Petal.Width
#> Sepal.Length    1.0000000  -0.1175698    0.8717538   0.8179411
#> Sepal.Width    -0.1175698   1.0000000   -0.4284401  -0.3661259
#> Petal.Length    0.8717538  -0.4284401    1.0000000   0.9628654
#> Petal.Width     0.8179411  -0.3661259    0.9628654   1.0000000

## Stratify by the three species: 3-sample correlation array.
corrarray(iris, "Species", output = "array")
#> , , Sample = setosa
#> 
#>               
#>                Sepal.Length Sepal.Width Petal.Length Petal.Width
#>   Sepal.Length    1.0000000   0.7425467    0.2671758   0.2780984
#>   Sepal.Width     0.7425467   1.0000000    0.1777000   0.2327520
#>   Petal.Length    0.2671758   0.1777000    1.0000000   0.3316300
#>   Petal.Width     0.2780984   0.2327520    0.3316300   1.0000000
#> 
#> , , Sample = versicolor
#> 
#>               
#>                Sepal.Length Sepal.Width Petal.Length Petal.Width
#>   Sepal.Length    1.0000000   0.5259107    0.7540490   0.5464611
#>   Sepal.Width     0.5259107   1.0000000    0.5605221   0.6639987
#>   Petal.Length    0.7540490   0.5605221    1.0000000   0.7866681
#>   Petal.Width     0.5464611   0.6639987    0.7866681   1.0000000
#> 
#> , , Sample = virginica
#> 
#>               
#>                Sepal.Length Sepal.Width Petal.Length Petal.Width
#>   Sepal.Length    1.0000000   0.4572278    0.8642247   0.2811077
#>   Sepal.Width     0.4572278   1.0000000    0.4010446   0.5377280
#>   Petal.Length    0.8642247   0.4010446    1.0000000   0.3221082
#>   Petal.Width     0.2811077   0.5377280    0.3221082   1.0000000

## Specify lower and upper samples: 2-sample correlation matrix.
corrarray(iris, "Species", lower = "setosa", upper = "virginica")
#> [1] "Sample1 (lower triangular matrix) is 'setosa' (n=50)."   
#> [2] "Sample2 (upper triangular matrix) is 'virginica' (n=50)."
#>               Sample2
#> Sample1        Sepal.Length Sepal.Width Petal.Length Petal.Width
#>   Sepal.Length    1.0000000   0.4572278    0.8642247   0.2811077
#>   Sepal.Width     0.7425467   1.0000000    0.4010446   0.5377280
#>   Petal.Length    0.2671758   0.1777000    1.0000000   0.3221082
#>   Petal.Width     0.2780984   0.2327520    0.3316300   1.0000000
Metadata

Version

1.2.0

License

Unknown

Platforms (77)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-windows
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows