Skip to contents

Convert objects to Momocs coordinate and coefficient classes.

Usage

as_coo(x)

as_out(x)

as_ldk(x)

as_xy(x)

as_ldk_id(x)

as_cur(x)

as_path(x)

as_coe(x)

as_eft(x)

as_dct(x)

as_npoly(x)

as_opoly(x)

as_proc(x)

Arguments

x

An object to coerce.

Value

Object with updated class attribute.

Details

List columns classes

  • as_coo(): list of generic coordinate objects

  • as_out(): list of outlines

  • as_ldk(): list of landmarks

  • as_cur(): list of curves (open outlines)

Single matrices

  • as_xy(): single xy matrix Non-coordinate classes:

  • as_ldk_id(): landmark identifiers (not inherits from coo)

  • as_path(): list of paths

Coefficient classes (all inherit from "coe"):

  • as_coe(): generic coefficient object

  • as_eft(): (out) Elliptic Fourier Transform coefficients

  • as_proc(): (ldk) Procrustes-aligned coefficients

  • as_dct(): (cur) Discrete Cosine Transform coefficients

  • as_npoly(): (cur) natural polynomial coefficients

  • as_opoly(): (cur) orthogonal polynomial coefficients

Examples

mat <- matrix(rnorm(100), ncol = 2)
as_coo(mat)
#>               [,1]        [,2]
#>  [1,]  0.255317055 -0.24323674
#>  [2,] -2.437263611 -0.20608719
#>  [3,] -0.005571287  0.01917759
#>  [4,]  0.621552721  0.02956075
#>  [5,]  1.148411606  0.54982754
#>  [6,] -1.821817661 -2.27411486
#>  [7,] -0.247325302  2.68255718
#>  [8,] -0.244199607 -0.36122126
#>  [9,] -0.282705449  0.21335575
#> [10,] -0.553699384  1.07434588
#> [11,]  0.628982042 -0.66508825
#> [12,]  2.065024895  1.11395242
#> [13,] -1.630989402 -0.24589641
#> [14,]  0.512426950 -1.17756331
#> [15,] -1.863011492 -0.97585062
#> [16,] -0.522012515  1.06505732
#> [17,] -0.052601910  0.13167063
#> [18,]  0.542996343  0.48862881
#> [19,] -0.914074827 -1.69945057
#> [20,]  0.468154420 -1.47073631
#> [21,]  0.362951256  0.28415034
#> [22,] -1.304543545  1.33732041
#> [23,]  0.737776321  0.23669628
#> [24,]  1.888504929  1.31829338
#> [25,] -0.097445104  0.52390979
#> [26,] -0.935847354  0.60674805
#> [27,] -0.015950311 -0.10993567
#> [28,] -0.826788954  0.17218172
#> [29,] -1.512399651 -0.09032729
#> [30,]  0.935363190  1.92434334
#> [31,]  0.176488611  1.29839276
#> [32,]  0.243685465  0.74879127
#> [33,]  1.623548883  0.55622433
#> [34,]  0.112038083 -0.54825726
#> [35,] -0.133997013  1.11053489
#> [36,] -1.910087468 -2.61233433
#> [37,] -0.279237242 -0.15569378
#> [38,] -0.313445978  0.43388979
#> [39,]  1.067307879 -0.38195111
#> [40,]  0.070034850  0.42418757
#> [41,] -0.639123324  1.06310200
#> [42,] -0.049964899  1.04871262
#> [43,] -0.251483443 -0.03810289
#> [44,]  0.444797116  0.48614892
#> [45,]  2.755417575  1.67288261
#> [46,]  0.046531380 -0.35436116
#> [47,]  0.577709069  0.94634789
#> [48,]  0.118194874  1.31682636
#> [49,] -1.911720491 -0.29664002
#> [50,]  0.862086482 -0.38721358
#> attr(,"class")
#> [1] "coo"    "matrix" "array" 
as_out(mat)
#>               [,1]        [,2]
#>  [1,]  0.255317055 -0.24323674
#>  [2,] -2.437263611 -0.20608719
#>  [3,] -0.005571287  0.01917759
#>  [4,]  0.621552721  0.02956075
#>  [5,]  1.148411606  0.54982754
#>  [6,] -1.821817661 -2.27411486
#>  [7,] -0.247325302  2.68255718
#>  [8,] -0.244199607 -0.36122126
#>  [9,] -0.282705449  0.21335575
#> [10,] -0.553699384  1.07434588
#> [11,]  0.628982042 -0.66508825
#> [12,]  2.065024895  1.11395242
#> [13,] -1.630989402 -0.24589641
#> [14,]  0.512426950 -1.17756331
#> [15,] -1.863011492 -0.97585062
#> [16,] -0.522012515  1.06505732
#> [17,] -0.052601910  0.13167063
#> [18,]  0.542996343  0.48862881
#> [19,] -0.914074827 -1.69945057
#> [20,]  0.468154420 -1.47073631
#> [21,]  0.362951256  0.28415034
#> [22,] -1.304543545  1.33732041
#> [23,]  0.737776321  0.23669628
#> [24,]  1.888504929  1.31829338
#> [25,] -0.097445104  0.52390979
#> [26,] -0.935847354  0.60674805
#> [27,] -0.015950311 -0.10993567
#> [28,] -0.826788954  0.17218172
#> [29,] -1.512399651 -0.09032729
#> [30,]  0.935363190  1.92434334
#> [31,]  0.176488611  1.29839276
#> [32,]  0.243685465  0.74879127
#> [33,]  1.623548883  0.55622433
#> [34,]  0.112038083 -0.54825726
#> [35,] -0.133997013  1.11053489
#> [36,] -1.910087468 -2.61233433
#> [37,] -0.279237242 -0.15569378
#> [38,] -0.313445978  0.43388979
#> [39,]  1.067307879 -0.38195111
#> [40,]  0.070034850  0.42418757
#> [41,] -0.639123324  1.06310200
#> [42,] -0.049964899  1.04871262
#> [43,] -0.251483443 -0.03810289
#> [44,]  0.444797116  0.48614892
#> [45,]  2.755417575  1.67288261
#> [46,]  0.046531380 -0.35436116
#> [47,]  0.577709069  0.94634789
#> [48,]  0.118194874  1.31682636
#> [49,] -1.911720491 -0.29664002
#> [50,]  0.862086482 -0.38721358
#> attr(,"class")
#> [1] "out"    "coo"    "matrix" "array" 
as_ldk(mat)
#>               [,1]        [,2]
#>  [1,]  0.255317055 -0.24323674
#>  [2,] -2.437263611 -0.20608719
#>  [3,] -0.005571287  0.01917759
#>  [4,]  0.621552721  0.02956075
#>  [5,]  1.148411606  0.54982754
#>  [6,] -1.821817661 -2.27411486
#>  [7,] -0.247325302  2.68255718
#>  [8,] -0.244199607 -0.36122126
#>  [9,] -0.282705449  0.21335575
#> [10,] -0.553699384  1.07434588
#> [11,]  0.628982042 -0.66508825
#> [12,]  2.065024895  1.11395242
#> [13,] -1.630989402 -0.24589641
#> [14,]  0.512426950 -1.17756331
#> [15,] -1.863011492 -0.97585062
#> [16,] -0.522012515  1.06505732
#> [17,] -0.052601910  0.13167063
#> [18,]  0.542996343  0.48862881
#> [19,] -0.914074827 -1.69945057
#> [20,]  0.468154420 -1.47073631
#> [21,]  0.362951256  0.28415034
#> [22,] -1.304543545  1.33732041
#> [23,]  0.737776321  0.23669628
#> [24,]  1.888504929  1.31829338
#> [25,] -0.097445104  0.52390979
#> [26,] -0.935847354  0.60674805
#> [27,] -0.015950311 -0.10993567
#> [28,] -0.826788954  0.17218172
#> [29,] -1.512399651 -0.09032729
#> [30,]  0.935363190  1.92434334
#> [31,]  0.176488611  1.29839276
#> [32,]  0.243685465  0.74879127
#> [33,]  1.623548883  0.55622433
#> [34,]  0.112038083 -0.54825726
#> [35,] -0.133997013  1.11053489
#> [36,] -1.910087468 -2.61233433
#> [37,] -0.279237242 -0.15569378
#> [38,] -0.313445978  0.43388979
#> [39,]  1.067307879 -0.38195111
#> [40,]  0.070034850  0.42418757
#> [41,] -0.639123324  1.06310200
#> [42,] -0.049964899  1.04871262
#> [43,] -0.251483443 -0.03810289
#> [44,]  0.444797116  0.48614892
#> [45,]  2.755417575  1.67288261
#> [46,]  0.046531380 -0.35436116
#> [47,]  0.577709069  0.94634789
#> [48,]  0.118194874  1.31682636
#> [49,] -1.911720491 -0.29664002
#> [50,]  0.862086482 -0.38721358
#> attr(,"class")
#> [1] "ldk"    "coo"    "matrix" "array" 

coefs <- rnorm(20)
as_eft(coefs)
#>  [1] -0.7854327 -1.0567369 -0.7955414 -1.7562754 -0.6905379 -0.5585420
#>  [7] -0.5366633  0.2271271  0.9784549 -0.2088827 -1.3994105  0.2585373
#> [13] -0.4417995  0.5685999  2.1268505  0.4248584 -1.6842815  0.2494018
#> [19]  1.0728383  2.0393693
#> attr(,"class")
#> [1] "eft"     "coe"     "numeric"
as_dct(coefs)
#>  [1] -0.7854327 -1.0567369 -0.7955414 -1.7562754 -0.6905379 -0.5585420
#>  [7] -0.5366633  0.2271271  0.9784549 -0.2088827 -1.3994105  0.2585373
#> [13] -0.4417995  0.5685999  2.1268505  0.4248584 -1.6842815  0.2494018
#> [19]  1.0728383  2.0393693
#> attr(,"class")
#> [1] "dct"     "coe"     "numeric"