factor.collapse.levels: Reduces common factor variables of two datasets to common...

Description Usage Arguments Value Examples

Description

Reduces common factor variables of two datasets to common levels

Usage

1
factor.collapse.levels(data1, data2, vars.list, tag = NA)

Arguments

data1

A data frame

data2

Another data frame

vars.list

A list of pairs (variable.name,variable.type) such as those produced by allvariables.manual.review

tag

(defaults to NA) A value that will replace levels that do not appear in both data1[[variable]] and data2[[variable]]

Value

A list of two modified data frames (list(newdata1,newdata2))

Examples

1
2
3
4
5
6
X <- data.frame(a = factor(sample(1:3,100,TRUE)),
                b = factor(sample(letters[1:5],100,TRUE)))
Y <- data.frame(a = factor(sample(2:4,50,TRUE)),
                b = factor(sample(letters[3:7],50,TRUE)))
Z <- factor.collapse.levels(X,Y)
head(cbind(X,Y,Z[[1]],Z[[2]]), 20)

ahdxb/data.exploration documentation built on May 11, 2019, 11:31 p.m.