Skip to contents

Helper function to "borrow" missing age groups from other years

Usage

fix_age_group(x, age = 0, n = 3, fun = "mean")

Arguments

x

DATRASraw object

age

age to impute

n

at least this many individuals in each year

fun

A function such as 'mean','median','min', or 'max'.

Value

a DATRASraw object

Details

In years where there are less than 'n' individuals of age 'age', add fake individuals of that age such that there are 'n'. The length of the individuals are set to the mean (or whatever 'fun' specifies) of all other individuals of the same age. For the minimum and maximum age groups fun it is reasonable to replace 'mean' with 'min' and 'max' respectively. Note, that you might need to call 'addSpectrum' on the object again.