How to run R Code in R Markdown file in SublimeREPL?

廉价感情. 提交于 2019-12-22 06:58:08

问题


I would like to test code parts in my R Markdown code without leaving Sublime Text.

For instance:

Multiplying the grades with two solves the unreliability problem:
```{r}
 chisq.test(2*grades)
```

In the above example, I would like to select the line that has the code "chisq.test(2*grades)", press my key combination, and have it ran in SublimeREPL as R code.

However, when I try this, I get the following error from SublimeREPL:

Cannot find REPL for 'HTML.markdown.rmarkdown'

When I change the syntax through view menu to "R" (rather than R Markdown), the code runs fine. This is a workaround though, and it is undesirable because it costs me R Markdown syntax highlighting.

I suspect the solution is simply copy-pasting a few lines of SublimeREPL package code and repurposing them for R Markdown, but I was unable to achieve any results yet. I'd appreciate any help.


回答1:


From this answer :

  1. Open the file SublimeREPL/config/R/Main.sublime-menu. Its default position depends on your system

    • Linux: ~/.config/sublime-text-3/Packages
    • Mac: ~/Library/Application Support/Sublime Text 3/Packages (untested)
    • Windows: %APPDATA%/Sublime Text 3/Packages (untested)
  2. Add your scode to the option "additional_scopes":

    "additional_scopes": ["HTML.markdown.rmarkdown","tex.latex.knitr"],
    
  3. Save the file, close the REPL tab, restart sublime, and open a new REPL instance.



来源:https://stackoverflow.com/questions/30082002/how-to-run-r-code-in-r-markdown-file-in-sublimerepl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!