# arrayspecs: Convert landmark data matrix into array (p x k x n) In geomorph: Geometric Morphometric Analyses of 2D/3D Landmark Data

## Description

Convert a matrix of landmark coordinates into a three-dimensional array

## Usage

 `1` ```arrayspecs(A, p, k, sep = NULL) ```

## Arguments

 `A` A matrix containing landmark coordinates for a set of specimens `p` Number of landmarks `k` Number of dimensions (2 or 3) `sep` An optional argument to attempt to separate variable names into landmark dimension and landmark number variables. For example, X.1, Y.1, Z.1, X.2, Y.2, Z.2, ..., can be separated with sep = ".", such that rows of landmark configurations are labeled 1, 2, 3, ..., and columns are labeled X, Y, Z. Note, for variables, X1, Y1, Z1, X2, Y2, Z2, ..., where no separator is evident, use sep = "". Any illogical separation argument will result in unlabeled variables. If sep = NULL (the default), unlabeled variables are forced. This is a good idea if the original matrix has landmarks out of order (as the the landmark labels might not sort as expected).

## Details

This function converts a matrix of landmark coordinates into a 3D array (p x k x n), which is the required input format for many functions in geomorph. The input matrix can be arranged such that the coordinates of each landmark are found on a separate row, or that each row contains all landmark coordinates for a single specimen.

## Value

Function returns a 3D array (p x k x n), where p is the number of landmark points, k is the number of landmark dimensions (2 or 3), and n is the number of specimens. The third dimension of this array contains names for each specimen if specified in the original input matrix.

## Author(s)

Dean Adams & Mike Collyer

`two.d.array`

## Examples

 ```1 2 3 4 5``` ```x<-matrix(rnorm(18),nrow=3) # Random triangles (all coordinates on same row for each triangle) arrayspecs(x,3,2) x2<-matrix(rnorm(18),ncol=2) # Random triangles (each landmark on its own row) arrayspecs(x2,3,2) ```

### Example output

```Loading required package: rgl
Warning messages:
1: In rgl.init(initValue, onlyNULL) : RGL: unable to open X11 display
2: 'rgl_init' failed, running with rgl.useNULL = TRUE
3: .onUnload failed in unloadNamespace() for 'rgl', details:
call: fun(...)
, , 1

[,1]       [,2]
[1,]  0.9561137 -0.5345095
[2,] -0.5495130 -1.1636817
[3,] -0.5923371 -1.9041433

, , 2

[,1]        [,2]
[1,] 2.150068  0.99067806
[2,] 0.834759 -0.46979553
[3,] 0.760206 -0.04214474

, , 3

[,1]       [,2]
[1,] -0.3584948 -0.9609366
[2,]  0.4070216  1.4890275
[3,] -2.6055512  1.7829203

, , 1

[,1]      [,2]
[1,]  0.6859624 0.9324403
[2,]  1.2136249 0.4693812
[3,] -0.3497965 1.4808698

, , 2

[,1]      [,2]
[1,] -1.5974528 0.2014794
[2,] -0.9397153 1.0729127
[3,] -0.5357972 0.3435349

, , 3

[,1]       [,2]
[1,] -0.00762821 -0.7508627
[2,] -1.98454813  0.3338575
[3,] -0.36410524 -1.0931938
```

geomorph documentation built on Aug. 10, 2017, 1:11 a.m.