handleNAsMean: handleNAsMean

View source: R/handleNAs.R

handleNAsMeanR Documentation

handleNAsMean

Description

Remove NAs from a vector by replacing them by the sample mean.

Usage

handleNAsMean(
  x,
  y = NULL,
  imputeCriteriaFuns = list(is.na, is.infinite, is.nan),
  penaltyImputation = 3
)

Arguments

x

The x values from which y was calculated, not used here

y

The vector of numerics from which the NAs should be removed

imputeCriteriaFuns

list criteria functions specified via imputeCriteriaFuns in spotControl. Default: list(is.na, is.infinite, is.nan).

penaltyImputation

penalty used for imputed values

Value

y The cleaned vector

Examples

vecWithNAs <- c(-1, 0,1,NA,3,Inf,5,NA)
control <- spotControl(dim=length(vecWithNAs))
print(vecWithNAs)
print(handleNAsMean(y=vecWithNAs,
                     imputeCriteriaFuns= control$yImputation$imputeCriteriaFuns))

SPOT documentation built on June 26, 2022, 1:06 a.m.