R/string_count.R

Defines functions string_count

# replacement for str_count()
string_count <- function(string, regex, fixed = TRUE){
  greg_out <- gregexpr(regex, string, fixed = fixed)
  count <- unlist(lapply(
    greg_out,
    function(x){
      length(x[x > 0])
    }))
  return(count)
}
palderman/DSSAT documentation built on Feb. 24, 2024, 4:38 a.m.