Skip to contents

Get Coordinates

Usage

get_coordinates(x, ...)

get_replications(x, ...)

# S4 method for class 'MultivariateAnalysis'
get_coordinates(x, margin = 1, principal = TRUE, sup_name = ".sup")

# S4 method for class 'PCOA'
get_coordinates(x)

# S4 method for class 'MultivariateBootstrap'
get_replications(x, margin = 1)

# S4 method for class 'BootstrapPCA'
get_replications(x)

Arguments

x

An object from which to get element(s) (a CA, MCA or PCA object).

...

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.

principal

A logical scalar: should principal coordinates be returned? If FALSE, standard coordinates are returned.

sup_name

A character string specifying the name of the column to create for supplementary points attribution (see below).

Value

  • get_coordinates() returns a data.frame of coordinates. An extra column (named after sup_name) is added specifying whether an observation is a supplementary point or not.

  • get_replications() returns an array of coordinates.

See also

Author

N. Frerebeau

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