array2matrix: Convert an array into a matrix

View source: R/morpho.R

array2matrixR Documentation

Convert an array into a matrix

Description

Convert an array with landmark points into an object of class matrix.

Usage

array2matrix(X, coords = c(2, 3))

Arguments

X

Array, k landmark points, q coordinates, and s specimens.

coords

Integer, 2 or 3, for 2D or 3D landmarks, respectively.

Details

The object X, class array, has format k x q x s, where k is the number of landmarks, q the number of coordinates, and s the number of specimens. See C.arr.unal for an example of the format of a 3D array and data-raw/C.R for the details about how to generate this object.

Value

An object of class matrix, with s rows, one for specimen, and n columns, one for each coordinate of the landmarks. Each landmark can be given in 2D or 3D. For instance, if the landmarks are 3D, the first 3 columns will be the coordinates x, y, and z for the first landmark, the next 3 columns for the second landmark, and so on.

specimens lmk1.x lmk1.y lmk1.z lmk2.x lmk2.y lmk2.z ...
Sp_1 0.143 -0.028 -0.044 0.129 0.028 -0.043 ...
Sp_2 0.128 -0.024 -0.028 0.124 0.027 -0.025 ...
... ... ... ... ... ... ... ...

See object C for a more detailed example of the format of the object that is returned and data-raw/C.R for the explanation about how to generate this object.

Note that if the names for the s matrices, one per specimen, in the array are not provided, i.e. the names for specimens are not given, the specimens in the returned matrix, row.names(matrix), will be labelled as '1', '2', and so on.

Author(s)

Sandra Alvarez-Carretero and Mario dos Reis

See Also

matrix2array, write.morpho


dosreislab/mcmc3r documentation built on March 29, 2024, 6:45 p.m.