Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
1 contributor

Users who have contributed to this file

30 lines (26 sloc) 1.08 KB
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/collapse_column.R
\name{collapse_column}
\alias{collapse_column}
\title{Collapse Factor Levels}
\usage{
collapse_column(df, column, by, factor_levels = NULL, new_column = NULL)
}
\arguments{
\item{df}{A data frame}
\item{column}{The column/factor of interest}
\item{by}{Character vector - input for grep}
\item{factor_levels}{Character vector - new levels for factor; default is input of >by<}
\item{new_column}{Character - name of new column that is added to the data frame}
}
\value{
Returns the same list but with data frames containing the expression values in a new colummn.
}
\description{
This function combines factor levels with similar names and adds a new column via simple regex.
}
\examples{
lungMeta <- collapse_column(lungMeta, column = "diagnoses.primary_diagnosis",
by = c("squamous", "adeno", "acinar", "bronchio"),
factor_levels = c("Squamous cell carninoma", "Adenocarcinoma", "Acinar carcinoma", "Bronchio-alveolar"), new_column = "diagnosis")
}