Learn R Programming

mmodely (version 0.2.5)

missing.fill.in: Fill in missing values in a dataframe with a secondary source

Description

This function uses the (non-missing) values from one column to fill in the missing values of another

Usage

missing.fill.in(x, var.from, var.to)

Value

a modified dataframe with fewer missing values in the 'var.to' column

Arguments

x

a dataframe or matrix

var.from

secondary variable (of the same type and units) providing values to 'var.to'

var.to

primary variable with missing values to fill in by 'var.from'

Examples

Run this code

df <- data.frame(a=c(1,2,NA),b=c(1,NA,3),c=c(1,2,6))
missing.fill.in(df, 'c','a')

Run the code above in your browser using DataLab