Tidy Coordinates
Usage
tidy(x, ...)
augment(x, ...)
# S4 method for class 'MultivariateAnalysis'
augment(x, ..., margin = 1, axes = c(1, 2), principal = TRUE)
# S4 method for class 'MultivariateAnalysis'
tidy(x, ..., margin = 1, principal = TRUE)
Arguments
- x
- ...
Currently not used.
- margin
A length-one
numeric
vector giving the subscript which the data will be returned:1
indicates individuals/rows (the default),2
indicates variables/columns.- axes
A length-two
numeric
vector giving the dimensions for which to compute results.- principal
A
logical
scalar: should principal coordinates be returned? IfFALSE
, standard coordinates are returned.
Value
tidy()
returns a long data.frame
with the following columns:
label
Row/column names of the original data.
component
Component.
supplementary
Whether an observation is active or supplementary.
coordinate
Coordinates.
contribution
Contributions to the definition of the components.
cos2
\(cos^2\).
augment()
returns a wide data.frame
of the row/column coordinates
along axes
and the following columns:
label
Row/column names of the original data.
supplementary
Whether an observation is active or supplementary.
mass
Weight/mass of each observation.
sum
Sum of squared coordinates along
axes
.contribution
Joint contributions to the definition of
axes
.cos2
Joint \(cos^2\) along
axes
.
See also
Other summary:
summary()
Examples
## Load data
data("iris")
## Compute principal components analysis
X <- pca(iris, scale = TRUE, sup_row = 5:10)
#> 1 qualitative variable was removed: Species.
## Get row principal coordinates
head(get_coordinates(X, margin = 1, principal = TRUE))
#> F1 F2 F3 .sup
#> 1 -2.385846 0.5084067 -0.12383101 FALSE
#> 2 -2.215654 -0.6515155 -0.23313750 FALSE
#> 3 -2.496566 -0.3169280 0.04974232 FALSE
#> 4 -2.433607 -0.5744432 0.09690301 FALSE
#> 11 -2.279483 1.0742447 -0.26629760 FALSE
#> 12 -2.450871 0.1591839 0.09988982 FALSE
## Get row standard coordinates
head(get_coordinates(X, margin = 1, principal = FALSE))
#> F1 F2 F3 .sup
#> 1 -1.403075 0.5268995 -0.3142569 FALSE
#> 2 -1.302987 -0.6752138 -0.5916536 FALSE
#> 3 -1.468187 -0.3284560 0.1262355 FALSE
#> 4 -1.431162 -0.5953380 0.2459193 FALSE
#> 11 -1.340525 1.1133193 -0.6758069 FALSE
#> 12 -1.441315 0.1649741 0.2534992 FALSE
## Tidy principal coordinates
head(tidy(X, margin = 1))
#> label component supplementary coordinate contribution cos2
#> 1 1 F1 FALSE -2.3858463 1.36709655 0.954033073
#> 2 1 F2 FALSE 0.5084067 0.19279380 0.043321256
#> 3 1 F3 FALSE -0.1238310 0.06858151 0.002570025
#> 4 10 F1 TRUE -2.3173283 NA 0.953213276
#> 5 10 F2 TRUE -0.4448514 NA 0.035127301
#> 6 10 F3 TRUE -0.2525218 NA 0.011319124
head(tidy(X, margin = 2))
#> label component supplementary coordinate contribution cos2
#> 1 Petal.Length F1 FALSE 0.99121597 33.97921607 0.9825091061
#> 2 Petal.Length F2 FALSE 0.01655680 0.02944324 0.0002741275
#> 3 Petal.Length F3 FALSE 0.05477927 1.93260521 0.0030007681
#> 4 Petal.Width F1 FALSE 0.96350955 32.10619376 0.9283506618
#> 5 Petal.Width F2 FALSE 0.05756108 0.35586957 0.0033132775
#> 6 Petal.Width F3 FALSE 0.24948796 40.08758618 0.0622442430
head(augment(X, margin = 1, axes = c(1, 2)))
#> F1 F2 label supplementary mass sum contribution
#> 1 -2.385846 0.5084067 1 FALSE 0.006944444 5.950740 4.132458
#> 2 -2.215654 -0.6515155 2 FALSE 0.006944444 5.333593 3.703884
#> 3 -2.496566 -0.3169280 3 FALSE 0.006944444 6.333284 4.398114
#> 4 -2.433607 -0.5744432 4 FALSE 0.006944444 6.252426 4.341962
#> 11 -2.314675 1.5154881 17 FALSE 0.006944444 7.654424 5.315572
#> 12 -2.310149 0.5163762 18 FALSE 0.006944444 5.603432 3.891272
#> cos2
#> 1 0.9973543
#> 2 0.9880287
#> 3 0.9995093
#> 4 0.9977072
#> 11 0.9953781
#> 12 0.9982426
head(augment(X, margin = 2, axes = c(1, 2)))
#> F1 F2 label supplementary mass sum contribution
#> 1 0.8875399 0.36087785 Sepal.Length FALSE 1 0.9179599 91.79599
#> 2 -0.4392190 0.89286998 Sepal.Width FALSE 1 0.9901302 99.01302
#> 3 0.9912160 0.01655680 Petal.Length FALSE 1 0.9827832 98.27832
#> 4 0.9635096 0.05756108 Petal.Width FALSE 1 0.9316639 93.16639
#> cos2
#> 1 0.9179599
#> 2 0.9901302
#> 3 0.9827832
#> 4 0.9316639