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)
}

Try the DSSAT package in your browser

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

DSSAT documentation built on Nov. 9, 2023, 1:08 a.m.