aggregate2sources: aggregates two variables from two sources into one

Description Usage Arguments Examples

View source: R/shorthands.R

Description

Takes two variables with different missings and gives one variable with values of the second variable substituted where the first had missings.

Usage

1
2
aggregate2sources(df, new_var, var1 = NULL, var2 = NULL,
  remove_old_variables = TRUE)

Arguments

df

data.frame or variable

new_var

new variable name

var1

first source. Assumed to be new_var.x (default suffixes after merging)

var2

second source. Assumed to be new_var.y (default suffixes after merging)

remove_old_variables

Defaults to not keeping var1 and var2 in the resulting df.

Examples

1
2
3
4
5
6
cars$dist.x = cars$dist
cars$dist.y = cars$dist
cars$dist.y[2:5] = NA
cars$dist.x[10:15] = NA # sprinkle missings
cars$dist = NULL # remove old variable
cars = aggregate2sources(cars, 'dist')

grebbel/formr_test documentation built on May 17, 2019, 8:34 a.m.