tests/testthat/_snaps/demean.md

demean works

Code
  head(x)
Output
    Sepal.Length_between Petal.Length_between Sepal.Length_within
  1             5.925000             3.527500          -0.8250000
  2             5.925000             3.527500          -1.0250000
  3             5.925000             3.527500          -1.2250000
  4             5.862222             3.951111          -1.2622222
  5             5.925000             3.527500          -0.9250000
  6             5.862222             3.951111          -0.4622222
    Petal.Length_within
  1           -2.127500
  2           -2.127500
  3           -2.227500
  4           -2.451111
  5           -2.127500
  6           -2.251111
Code
  head(x)
Output
    Sepal.Length_between Species_between binary_between Species_setosa_between
  1             5.925000        0.850000          0.375              0.4250000
  2             5.925000        0.850000          0.375              0.4250000
  3             5.925000        0.850000          0.375              0.4250000
  4             5.862222        1.133333          0.400              0.2888889
  5             5.925000        0.850000          0.375              0.4250000
  6             5.862222        1.133333          0.400              0.2888889
    Species_versicolor_between Species_virginica_between Sepal.Length_within
  1                  0.3000000                 0.2750000          -0.8250000
  2                  0.3000000                 0.2750000          -1.0250000
  3                  0.3000000                 0.2750000          -1.2250000
  4                  0.2888889                 0.4222222          -1.2622222
  5                  0.3000000                 0.2750000          -0.9250000
  6                  0.2888889                 0.4222222          -0.4622222
    Species_within binary_within Species_setosa_within Species_versicolor_within
  1      -0.850000        -0.375             0.5750000                -0.3000000
  2      -0.850000         0.625             0.5750000                -0.3000000
  3      -0.850000        -0.375             0.5750000                -0.3000000
  4      -1.133333         0.600             0.7111111                -0.2888889
  5      -0.850000         0.625             0.5750000                -0.3000000
  6      -1.133333        -0.400             0.7111111                -0.2888889
    Species_virginica_within
  1               -0.2750000
  2               -0.2750000
  3               -0.2750000
  4               -0.4222222
  5               -0.2750000
  6               -0.4222222

demean interaction term

Code
  demean(dat, select = c("a", "x*y"), group = "ID")
Output
    a_between x_y_between   a_within x_y_within
  1  2.666667    4.666667 -1.6666667 -0.6666667
  2  2.333333    4.000000 -0.3333333  2.0000000
  3  2.500000    4.500000  0.5000000 -1.5000000
  4  2.666667    4.666667  1.3333333  3.3333333
  5  2.333333    4.000000 -1.3333333  0.0000000
  6  2.500000    4.500000 -0.5000000  1.5000000
  7  2.666667    4.666667  0.3333333 -2.6666667
  8  2.333333    4.000000  1.6666667 -2.0000000


Try the datawizard package in your browser

Any scripts or data that you put into this service are public.

datawizard documentation built on Sept. 15, 2023, 9:06 a.m.