str_begins: Detect strings beginning with some substring

str_beginsR Documentation

Detect strings beginning with some substring

Description

helpful to combine with filter()

Usage

str_begins(x, pattern)

Arguments

x

character vector

pattern

substring that you want to detect

Examples

x <- c("C22240098", "C22250098", "C22240189", "G1003260")
x %>% str_begins("G")
x %>% str_begins("C22")

library(tidyverse)
df <- tibble(src_code = x)
df %>% filter(src_code %>% str_begins("G"))
df %>% filter(src_code %>% str_begins("C22"))


BAAQMD/strtools documentation built on Nov. 23, 2023, 5:52 a.m.