#' Match Based on Two Strings
#'
#' @param match1 First string
#' @param match2 Second string
#'
#' @return Indices to be used by \code{dplyr::select} etc.
#' @export
#'
#' @examples
#' library(dplyr)
#' # Select columns containing a and r
#' mtcars %>% select_at(vars(match2("r", "a")))
#'
match2 <- function(match1, match2) {
intersect(tidyselect:::grep_vars(needle = match1, haystack = tidyselect::peek_vars()),
tidyselect:::grep_vars(needle = match2, haystack = tidyselect::peek_vars()))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.