R/filter_element.R

Defines functions filter_element

Documented in filter_element

#' Remove Elements in a Vetor
#' 
#' Removes the matching elements of a vector.
#' 
#' @param x A character vector.
#' @param pattern A regex pattern to match for exclusion.
#' @param \ldots Other arguments passed to \code{\link[base]{grep}}.
#' @return Returns a vector with matching elements removed.
#' @export
#' @examples 
#' x <- c('dog', 'cat', 'bat', 'dingo', 'dragon', 'dino')
#' filter_element(x, '^d.+?g')
#' filter_element(x, 'at$')
#' filter_element(x, '^d')
#' filter_element(x, '\\b(dog|cat)\\b')
filter_element <- function(x, pattern, ...){
    
    warning(
        paste(
            "Deprecated, use textclean::drop_elements() instead.",
            "`filter_element()` will be removed in the next version."
        ),
        call. = FALSE
    )
    
    grep(pattern, x, value =  TRUE, invert = TRUE, perl = TRUE, ...)
}

Try the textclean package in your browser

Any scripts or data that you put into this service are public.

textclean documentation built on May 2, 2019, 7:22 a.m.