interact.all: Compute all pairwise interactions between the columns of a...

Description Usage Arguments Value Examples

View source: R/int.R

Description

The function multiplies the columns (variables) of a matrix or a data.frame with each other, and produces a new matrix where all pairwise interactions are present. This also includes multiplying a column with its self, thus effectively returning a squared column.

Usage

1
interact.all(input)

Arguments

input

A data matrix (of class matrix or data.frame) for which all column-wise multiplications are to be computed

Value

A matrix where columns of the original data matrix have been multiplied, indicating column names coupled with a colon in-between

Examples

1
2
3
4
5
set.seed(1)
somedata <- data.frame(a = rnorm(10), b = rnorm(10), c = runif(10), d = runif(10))
somedata
allinteract <- interact.all(somedata)
allinteract

Example output

Attaching package:ePCRThe following object is masked frompackage:graphics:

    plot

The following object is masked frompackage:base:

    plot

            a           b         c          d
1  -0.6264538  1.51178117 0.8209463 0.47761962
2   0.1836433  0.38984324 0.6470602 0.86120948
3  -0.8356286 -0.62124058 0.7829328 0.43809711
4   1.5952808 -2.21469989 0.5530363 0.24479728
5   0.3295078  1.12493092 0.5297196 0.07067905
6  -0.8204684 -0.04493361 0.7893562 0.09946616
7   0.4874291 -0.01619026 0.0233312 0.31627171
8   0.7383247  0.94383621 0.4772301 0.51863426
9   0.5757814  0.82122120 0.7323137 0.66200508
10 -0.3053884  0.59390132 0.6927316 0.40683019
          a:a          a:b         a:c         a:d          b:b           b:c
1  0.39244438 -0.947061074 -0.51428493 -0.29920663 2.2854823013  1.2410911478
2  0.03372487  0.071592108  0.11882828  0.15815537 0.1519777490  0.2522520401
3  0.69827518  0.519126404 -0.65424102 -0.36608648 0.3859398589 -0.4863896038
4  2.54492084 -3.533068213  0.88224821  0.39052040 4.9048955903 -1.2248094570
5  0.10857537  0.370673480  0.17454672  0.02328930 1.2654695706  0.5958979337
6  0.67316837  0.036866606 -0.64764183 -0.08160884 0.0020190292 -0.0354686243
7  0.23758708 -0.007891605  0.01137231  0.15416002 0.0002621246 -0.0003777383
8  0.54512337  0.696857592  0.35235075  0.38292049 0.8908267926  0.4504270162
9  0.33152416  0.472843850  0.42165259  0.38117018 0.6744042513  0.6013915637
10 0.09326207 -0.181370567 -0.21155217 -0.12424121 0.3527187793  0.4114141866
            b:d         c:c         c:d         d:d
1   0.722056350 0.673952818 0.392100059 0.228120503
2   0.335736690 0.418686894 0.557254371 0.741681763
3  -0.272163701 0.612983710 0.343000578 0.191929075
4  -0.542152502 0.305849162 0.135381783 0.059925707
5   0.079509045 0.280602834 0.037440075 0.004995528
6  -0.004469374 0.623083261 0.078514233 0.009893517
7  -0.005120522 0.000544345 0.007378999 0.100027793
8   0.489505798 0.227748535 0.247507863 0.268981499
9   0.543652600 0.536283412 0.484795413 0.438250721
10  0.241616986 0.479877009 0.281824109 0.165510801

ePCR documentation built on Dec. 1, 2019, 1:21 a.m.

Related to interact.all in ePCR...