Select Git revision
equalizeLevels.Rd
-
Walmes Zeviani authoredWalmes Zeviani authored
equalizeLevels.Rd 1.41 KiB
% Generated by roxygen2 (4.1.1): do not edit by hand
% Please edit documentation in R/equalizeLevels.R
\name{equalizeLevels}
\alias{equalizeLevels}
\title{Make that to data frames have the same factor levels}
\usage{
equalizeLevels(target, ref)
}
\arguments{
\item{target}{the target data frame that will have factor levels
reordered.}
\item{ref}{the reference data frame that contains the desired level
order.}
}
\value{
the first data data frame with the levels in a new order.
}
\description{
If two data frames have factor or character columns with
the same name, those in the first will have the same level order
as those in the second. So, in terms of factor columns, these
data frames will have the same levels in the same
order. Character columns in the first will be converted to factor
if they aren't. This function is useful to assing to the data
frame returned in the \code{grid} attribute returned by
\code{doBy::LSmeans()} or \code{doBy::LSmatrix()} the same order
to the levels present in the data frame used to fit the model and
estimate the parameters.
}
\examples{
a <- data.frame(
Species=as.character(sample(iris$Species, size=10, replace=TRUE)),
stringsAsFactors=FALSE)
str(a)
levels(a$Species)
levels(iris$Species)
b <- equalizeLevels(target=a, ref=iris)
str(b)
}
\author{
Walmes Zeviani, \email{walmes@ufpr.br}
}
\seealso{
\link[doBy]{LSmeans}, \link[doBy]{LSmatrix}.
}