make.countarray: Count the number of observations in a dataframe or an 'mdf'...

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/make.countarray.R

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

1

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
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)

Example output

Loading required package: MASS
Loading required package: Matrix
Loading required package: nadiv
Loading required package: robustbase
Loading required package: pls

Attaching package: 'pls'

The following object is masked from 'package:stats':

    loadings

     Cww Diam Bwt
Cww   37   37  37
Diam  37   38  38
Bwt   37   38  38

dmm documentation built on Jan. 20, 2018, 9 a.m.