Home > database >  na_real_ using wordcountAddin
na_real_ using wordcountAddin

Time:01-18

I was just wondering what could be happening here. I tried reinstalling the package, but for some reason, wordcountaddin by benmarwick is still producing NA_Real_ in the environment.

wc_file<- wordcountaddin::text_stats("file.rmd")[3] %>%
  str_extract("[0-9] ") %>% as.numeric()

CodePudding user response:

You might try stringi::stri_extract,

md <- system.file(package="plyr", "NEWS.md")

wordcountaddin::text_stats(md)[3] |>
  stringi::stri_extract(regex='[0-9] ') |> as.numeric()
# [1] 2748

however, the package (version 0.3.0.9000) has already a builtin word count function.

wordcountaddin::word_count(md)
# [1] 2748

If you still get NA, there might be an issue with your .Rmd file (e.g. only code, language package not available).

  • Related