Learn R Programming

StereoMorph (version 1.6.7)

readLandmarksToMatrix: Reads a landmark file or files into a matrix

Description

Reads landmarks from one or more files into a matrix. A single file or vector of files can be input. If more than one file is input, each matrix will be appended to the previous one with matching landmarks in the same row.

Usage

readLandmarksToMatrix(file, na.omit = FALSE, ...)

Arguments

file

a single landmark file or vector of landmark files to be read. Each file should contain a single landmark matrix.

na.omit

whether landmarks with NA values in any file should be omitted.

...

further arguments to be passed to read.table().

Value

a landmark matrix

Details

This function will read a landmark matrix from one or more files and use the row names in each matrix to match corresponding landmarks into a single matrix, filling in missing landmarks with NA. The rows correspond to landmarks and the columns correspond to the number of landmark dimensions (2 for 2D landmarks, 3 for 3D landmarks, etc.). Each landmark matrix is appended as new columns onto the existing matrix. So, if three, 2D landmark files are input the resulting matrix would have six columns.

The landmark files are read by read.file() and should thus conform to all requirements of read.file(). Arguments for read.file() can be passed through readLandmarksToList() (e.g. header, row.names, etc.). All landmark matrices must have row names.

See Also

readLandmarksToList, readLandmarksToArray, readCheckerboardsToArray

Examples

Run this code
# NOT RUN {
## GET FILE DIRECTORY FOR PACKAGE FILES
fdir <- paste0(path.package("StereoMorph"), "/extdata/")

## SET FILES TO LOAD
file <- paste0(fdir, "lm_2d_a3_v", 1:2, "_wna.txt")

## LOAD FILES INTO A MATRIX
readLandmarksToMatrix(file=file, row.names=1)

## LOAD FILES INTO A MATRIX OMITTING NAS
readLandmarksToMatrix(file=file, row.names=1, na.omit=TRUE)
# }

Run the code above in your browser using DataLab