This may seem really simple, but are you saving the Rmd file after making the changes? Further, note that the function does not count words inside code chunks. I tested the function with a *.rmd file on my machine and it seems to respond appropriately to word additions or deletions.