fillVec: Add missing elements to a vector of consecutive numbers

View source: R/fillVec.R

fillVecR Documentation

Add missing elements to a vector of consecutive numbers

Description

Fill a vector, which should be of consecutive numbers, but due to missings is not containing only consecutive numbers (e.g., the residuals of a lm()) with values (default is NA). Optionally fill a second parallel vector also with replValue

Usage

fillVec(x, y = NULL, replValue = NA, verbose = FALSE)

Arguments

x

A numeric vector which should contain consecutive numbers, but isn't.

y

An optional second parallel vector which is also filled with replValue.

replValue

A numeric atomic vector which is used for replacement (default is NA).

verbose

Logical value, if verbose output should be given (default is FALSE).

Value

Returns a numeric vector in which missing consecutive values are replaced by replValue (e.g., NA).

Author(s)

Axel Zinkernagel zinkernagel@uni-landau.de

Examples

data <- c(1,2,3,4,5,6,7,8,10,11,12,13,16,17,18,20,25,30)
dataMod <- fillVec(data, verbose = TRUE)

y <- rnorm(18, -1, 1)
dataMod2 <- fillVec(data, y, verbose = TRUE)


axzinker/axBoost documentation built on July 4, 2024, 9:14 p.m.