fill_in: Fill missing values in a vector

View source: R/misc functions.R

fill_inR Documentation

Fill missing values in a vector

Description

This function takes a vector containing missing values ("" or NA), and overwrites empty positions with the previous non-missing entry. This assumes the first value is not a missing value.

Usage

fill_in(data)

Arguments

data

a vector containing "" or NA as missing values.

Details

The motivating example for this was to automatically fill in cells in BODC nutrient data where metadata is not copied past the first row of a block of data representing a single CTD cast.

Value

A filled in vector where "" or NA is replaced with the latest non-missing value.

Examples

# Create dummy data with missing entries
test <- c(1, 2, "", "", NA, 3, "")

# Replace blanks
filled <- fill_in(test)

Jack-H-Laverick/MiMeMo.tools documentation built on March 6, 2023, 3:44 p.m.