Learn R Programming

rv (version 0.949)

imputeIntoTemplate: Force a vector into specified shape

Description

imputeintoTemplate imputes 'x' into the array shape given by 'template', which is a logical array of the desired dimension (usually the dimnames are also important!)

Usage

imputeIntoTemplate(x, template)

Arguments

x
a vector with the name attributes set
template
a named list of templates

Details

The template is a list with names matching the names of the components of 'x'. The components of the list are vectors or arrays of logical values (and NAs) with (typically) dimnames set.

The values in the components of the template vector/array determine how the imputation is to be done.

A 'TRUE' value indicates a component that is replaced by a value in x.

Value 'FALSE' indicates a component that is NOT imputed, but skipped and later imputed an 'NA'.

A component with 'NA' in the template is imputed but it is later masked with an 'NA'.

Thus only components with the value 'TRUE' will appear non-NA in the return value.

Examples

Run this code
#

Run the code above in your browser using DataLab