Skip to contents

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.

Value

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

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.

Examples

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

# Replace blanks
filled <- fill_in(test)