#' Subset plates from a dataset
#'
#' For now, \code{filter_plates} only supports positive parameters, i.e. the plates to
#' be selected (not the plates to be ignored). In the future, this behavior may
#' to be more similar to vector subsetting.
#'
#' @param df The dataset from which to extract data
#' @param plates The plates to select. If \code{NULL}, this function is a no-op.
#' @param filter.var The variable to filter on (default: \code{"Plate"}).
#'
#' @return The subsetted data frame, with only the requested plates.
#' @export
#' @importFrom magrittr %>%
#' @importFrom dplyr filter
#'
#' @examples
#' filter_plates(some.df)
#' filter_plates(some.df, c(1, 2))
filter_plates <- function(df, plates = NULL, filter.var = "Plate") {
if (is.null(plates)) {
df
} else {
df %>% filter(is.element(.[,filter.var], plates))
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.