R/filter.R

#' Pipe operator
#'
#' @name %>%
#' @rdname pipe
#' @keywords internal
#' @export
#' @importFrom magrittr %>%
#' @usage lhs \%>\% rhs
NULL

#' Filter tidy datasets by common sample IDs
#'
#' @description
#' Filter the tidy data set to include only the rows with a value for
#' \code{sample} that is found in all datasets. For the \code{mutations} and
#' \code{cnvs} datasets, call the corresponding \code{tidy_datasetname()}
#' function to get a tidy version of the dataset. For the \code{phenotypes}
#' dataset, call directly on the dataset; it is already tidy.
#'
#' @seealso \code{\link{common_samples}}
#'
#' @return A filtered version of a \code{sambcdata} dataset, including only
#'   samples that are common in all datasets.
#'
#' @examples
#' filter_by_common_samples(phenotypes)
#' filter_by_common_samples(tidy_mutations())
#' tidy_cnvs %>% filter_by_common_samples()
#'
#' @export
filter_by_common_samples <- function(data) {
  data %>%
    dplyr::filter(sample %in% common_samples)
}
shunsambongi/sambcdata documentation built on May 24, 2019, 5:05 a.m.