make.countarray {dmm}R Documentation

Count the number of observations in a dataframe or an mdf object for all traitpairs in the supplied list of traits.

Description

For some of the traits in a dataframe or an mdf object there may be missing observations, coded as NA, on some individuals. The function make.countarray assembles an array containing observation counts for all pairs of traits from the supplied vector of trait names.

Usage

make.countarray(mdf, traits)

Arguments

mdf

A dataframe or an object of class mdf. If made with function mdf() the argument keep=TRUE should be used, because the traits must be present as dataframe columns.

traits

A vector of the names of traits given as character strings

Details

This function may be useful if the number of observations varies between traits and one is planning to do a dmm() analysis with either the traitspairwise or traitsblockwise option.

Value

An array object with 2 dimensions, both of size equal to the number of traits in argument traits. Rows and columns are labelled with trait names. Each element is a count of the number of observations not equal to NA for a pair of traits.

Author(s)

Neville Jackson

See Also

Functions dmm(), mdf()

Examples

library(dmm)
# prepare the dataset sheep.df
data(sheep.df)
# count the observations
countarray <- make.countarray(sheep.df,c("Cww","Diam","Bwt"))
# lookat the counts
print(countarray)
#cleanup
rm(sheep.df)
rm(countarray)

[Package dmm version 2.1-10 Index]