word_count: Produce a word count for an R Markdown document

Description Usage Arguments Details Value

View source: R/word_count.R

Description

When producing a PDF document via LaTeX (via R Markdown), word count options are often unsatisfactory. Using command line tools such as pdftototex + wc can notoriously overcount; for example, it would include page numbers as well as sometimes axis labels (and axis tick labels) in word counts. Many publishers also consider tools like texcount to notoriously undercount. This function attempts to get an accurate word count for an R Markdown document that will be rendered to PDF via LaTeX. As with any option, it will be imperfect, but it tends to provide counts between using texcount or the pdftotext + wc options, so it should be fairly accurate.

Usage

1
word_count(path)

Arguments

path

A character vector of lenth one; the path to the file for which a word count is desired

Details

NOTE: This function will only work if you have the packages bibtex and RefManageR installed. As the bibtex package is currently in "orphaned" status on CRAN, it is not listed as a strict requirement as this package, so installing this package does not automatically install bibtex and you will have to manually install it yourself via install.packages.

Value

A named numeric vector of class "wordcount". The vector separately lists word counts for: (1) text, including section headings and footnotes; (2) captions and subcaptions; (3) citations in the text; (4) the references section; and (5) the total word count of all of the above.


duckmayr/draft documentation built on Dec. 20, 2021, 2:14 a.m.