equallevels: Make Two Data Frames Have The Same Factor Levels

Description Usage Arguments Value Author(s) Examples

View source: R/equallevels.R

Description

If two data frames have factors ou characters columns with the same column names, those in the first will have the same level order as those in the second. So, for factors, these data frames will have the same levels in the same order. Characters in the first will be converted to factor.

Usage

1

Arguments

x

the target data frame.

y

the reference data frame.

Value

the restructured data frame.

Author(s)

Walmes Zeviani, walmes@ufpr.br.

Examples

1
2
3
4
5
6
7
a <- data.frame(Species = as.character(
                    sample(iris$Species, size = 20, repl = TRUE)),
                stringsAsFactors = FALSE)
str(a)

b <- equallevels(a, iris)
str(b)

walmes/wzRfun documentation built on Aug. 10, 2021, 2:19 p.m.