FillDown: Fills in missing (NA) values with the previous non-missing...

Description Usage Arguments Value Examples

Description

Fills in missing (NA) values with the previous non-missing value

Usage

1
FillDown(data, Var)

Arguments

data

a data frame. Optional as you can simply specify a vector with Var,

Var

the variable in data or a vector you would like to fill down missing (NA) values.

Value

data frame

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# Create fake data
id <- c('Algeria', NA, NA, NA, 'Mexico', NA, NA)
score <- rnorm(7)
Data <- data.frame(id, score)

# FillDown id
DataOut <- FillDown(Data, 'id')

## Not run: 
# Use group_by and mutate from dplyr to FillDown grouped data, e.g.:
Example <- Example %>% group_by(grouping) %>% 
             mutate(NewFilled = FillDown(Var = VarToFill))

## End(Not run)

DataCombine documentation built on May 2, 2019, 11:26 a.m.