Wordcountaddin shows NA_Real

32 Views Asked by At

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.

1

There are 1 best solutions below

0
jay.sf On

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