This package aims to provide grammar check in R, specially for RStudio users editing notebooks. As some tools like Grammarly and LanguageTool are not (yet) directly integrated to the IDE, this is a temporary solution.
rspell
uses the LanguageTool API
and can verify grammar for several languages and was inspired by the
ggspell
package.
First, install the package.
remotes::install_github("rfsaldanha/rspell")
Then, select some text on RStudio (notebook, script, documentation…) and
run the check_selection
command at the console.
rspell::check_selection()
Possible grammar errors will be shown at the console, and you will be asked to modify or not the text.
For a faster use, you can use the package’s RStudio add-in. After
installing the package, it will be available at the add-in list. You can
also map a keyboard
shortcut
for it, like Ctrl+g
.
The package will prioritize the spelling dictionary set on RStudio’s project configuration.
Tools --> Project Options... --> Spelling --> Main dictionary language
If not set, the project will use the spelling dictionary set on the Global Options.
Tools --> Global Options... --> Spelling --> Main dictionary language
You can also manually specify the language.
rspell::check_selection(language = "FR")
If you set language = "auto"
, the LanguageTool API will try to guess
the language.
The available list of language codes is listed with the function
get_languages()
.
The package will skip spelling errors that are listed on the RStudio user’s dictionary:
Tools --> Global options... --> Spelling --> Edit User Dictionary...
It is possible to just show the errors without asking to change the selection.
rspell::check_selection(ask_modify = FALSE)