R/wordcount.R

Defines functions wordcount

Documented in wordcount

#' wordcount
#'
#' Count the number of distinct words in a sentence.
#'
#' @param x String variable or vector.
#'
#' @return Wordcount variable or vector.
#' @export
#'
#' @examples
#' \dontrun{
#' }
#'

wordcount <- function(x) {

  stringr::str_count(x,
                     '[A-z]\\W+') + 1L

}
toddellis/miao documentation built on June 1, 2025, 10:11 p.m.