R/type.r

Defines functions type

Documented in type

#' finds essay type in a folder of texts read into readtext
#' @param b path to file folder with multiple .docx essays.
#' @return a list with essay type (viz. on demand, range of writing, etc.)
#' @export

type <- function(b){
  d <- readtext::readtext(b)
  e <- d$text
  f <- purrr::map(e, ~strsplit(., "\\n")) # split by new space
  g <- purrr::map(f, ~unlist(.)) # get it into s aimpler list of lists
  h <- purrr::map(g, ~grep("Type[[:blank:]].*$", ., value = TRUE))
  return(h)
}
cownr10r/teachr documentation built on Nov. 4, 2019, 9:14 a.m.