R/n-words.R

Defines functions n_words

Documented in n_words

#' Return the number of words in a string
#'
#' @param x a string
#'
#' @return vector of numbers
#' @export
#'
#' @examples
#' syn_end <- syn("end")
#' syn_end_words <- n_words(syn_end)
#' syn_end[syn_end_words <= 1]
n_words <- function(x){
  lengths(strsplit(x, " "))
}

Try the syn package in your browser

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

syn documentation built on Dec. 20, 2019, 5:07 p.m.