Permalink
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?
mmRmeta/man/collapse_column.Rd
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
30 lines (26 sloc)
1.08 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% 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") | |
} |