Adam Ryczkowski
Adam Ryczkowski

Reputation: 8064

How to spellcheck R comments with RStudio on R source files?

How to conveniently spellcheck R comments with RStudio on R source files?

I am writing a package and I want it to look professional. Thanks to Oxygen, all package's documentation lives in R comments, which by default is excluded from spell checking. So even if spell checking functionality does exist in RStudio, I don't know how to use it.

Upvotes: 11

Views: 1516

Answers (3)

JSteele
JSteele

Reputation: 11

Well this is moot now that Rstudio has spellcheck for spin documents!

So, I write a lot of my lessons and examples for teaching using spin rather than markdown. It just makes for an easier flow. The problem is that there is no spell-check in a spin document, much like your package documentation example. What I have resorted to is using the terminal then running a command line spellchecker on the document.

I'm on linux so here is my workflow.

  1. save the file I am working let's say example_lesson.R (typos and all)
  2. open the terminal pane of Rstudio and cd to the right folder
  3. make sure the file example_lesson.R is there
  4. run the spell-checker
> aspell check example_lesson.R

Once I'm done with aspell, I go back to the editor window in Rstudio and it updates what I am working on with the spell-checked version. I spin it and I am done.

I've only tested with small examples, but it has worked thus far. Your mileage may vary. Hope that helps.

Upvotes: 0

Oscar Kjell
Oscar Kjell

Reputation: 1651

RStudio 1.3 will include this feature; and it is possible to already try it out.

Upvotes: 2

shiro
shiro

Reputation: 610

The spelling package is great for this: https://github.com/ropensci/spelling.

devtools::install_github("ropensci/spelling")
spelling::spell_check_package() # path to package Project

Upvotes: 4

Related Questions