matrix2array: Convert a matrix into an array

View source: R/morpho.R

matrix2arrayR Documentation

Convert a matrix into an array

Description

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

Usage

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

Arguments

X

Matrix of size s x n, n landmark points for s specimens (see details).

coords

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

Details

The matrix has format s x n, with s rows, one per 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 an example of its format and data-raw/C.R to see how this object is generated.

Value

An object of class array with format k x q x s, where k is the number of landmarks, q the number of coordinates, and s the number of specimens.

Note that if the matrix provided does not have rownames, the specimens in the returned array (names for the 's' matrices accessed through the array, i.e. dimnames( array )[ 3 ] will be labelled as '1', '2', and so on. See object C.arr.unal for an example of the format of the object that is returned and data-raw/C.R for the description of how to obtain this object.

Author(s)

Sandra Alvarez-Carretero and Mario dos Reis

See Also

array2matrix, write.morpho


dosreislab/mcmc3r documentation built on July 21, 2024, 3:23 a.m.