Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

vecx

convert an 3D array into a matrix and back


Description

converts a 3D-array (e.g. containing landmark coordinates) into a matrix, one row per specimen or reverse this.

Usage

vecx(x, byrow = FALSE, revert = FALSE, lmdim)

Arguments

x

array or matrix

byrow

logical: if TRUE, the resulting vector for each specimen will be x1,y1,z1,x2,y2,z2,..., and x1,x2,...,y1,y2,...,z1,z2,... otherwise (default). The same is for reverting the process: if the matrix contains the coordinates as rows like: x1,y1,z1,x2,y2,z2,... set byrow=TRUE

revert

revert the process and convert a matrix with vectorized landmarks back into an array.

lmdim

number of columns for reverting

Value

returns a matrix with one row per specimen

Author(s)

Stefan Schlager

Examples

if (require(shapes)) {
data <- vecx(gorf.dat) 
#revert the procedure
gdat.restored <- vecx(data,revert=TRUE,lmdim=2)
range(gdat.restored-gorf.dat)
}

Morpho

Calculations and Visualisations Related to Geometric Morphometrics

v2.8
GPL-2
Authors
Stefan Schlager [aut, cre, cph], Gregory Jefferis [ctb], Dryden Ian [cph]
Initial release
2020-02-26

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.