Vim plugin for R
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Just found a very nice plugin for using R in Vim. It’s unbelievable comfortable!
There are at least two ways to install it. If your are working on a Debian based distro you can use the .deb
package provided by the author Jakson Alves de Aquino itself. On this site you’ll also find some smart screen shots.
Another way is the installation by hand (I did so). Download the package, in your download directory type something like this:
1 2 | mkdir -p ~/.vim unzip vim-r-plugin-*.zip -d ~/.vim |
Yes, that’s it!
To start an R session just open a R-file (.R
or .Rnw
or .Rd
) with vim and type \rf
. To close the session type \rq
(not saving hist) or \rw (saving history).
The handling needs to getting used to.. Here is a list of common commands from the documentation (might want to print them as a cheat sheet!?) :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | Start/Close . Start R (default) \rf . Start R –vanilla \rv . Start R (custom) \rc ———————————————————- . Close R (no save) \rq . Close R (save workspace) \rw ————————————————————- Send . File \aa . File (echo) \ae . File (open .Rout) \ao ——————————————————– . Block (cur) \bb . Block (cur, echo) \be . Block (cur, down) \bd . Block (cur, echo and down) \ba ——————————————————– . Function (cur) \ff . Function (cur, echo) \fe . Function (cur and down) \fd . Function (cur, echo and down) \fa ——————————————————– . Selection \ss . Selection (echo) \se . Selection (and down) \sd . Selection (echo and down) \sa ——————————————————– . Paragraph \pp . Paragraph (echo) \pe . Paragraph (and down) \pd . Paragraph (echo and down) \pa ——————————————————– . Line \l . Line (and down) \d . Line (and new one) \q ———————————————————– Control . List space \rl . Clear console \rr . Clear all \rm ——————————————————– . Object (print) \rp . Object (names) \rn . Object (str) \rt ——————————————————– . Arguments (cur) \ra . Example (cur) \re . Help (cur) \rh ——————————————————– . Summary (cur) \rs . Plot (cur) \rg . Plot and summary (cur) \rb ——————————————————– . Update Object Browser \ro . Set working directory (cur file path) \rd . Build R tags file :RBuildTags . Build omniList (loaded packages) :RUpdateObjList . Build omniList (installed packages) :RUpdateObjListAll ——————————————————– . Sweave (cur file) \sw . Sweave and PDF (cur file) \sp . Go to next R chunk gn . Go to previous R chunk gN ——————————————————– |
But if you got used to, it’s very handy! At the start-up it opens a new R-console (just close it, doesn’t matter) and you can send single lines, a block or a whole file to R (see the documentation). Every thing I tried worked really fine!
A small example in action is presented in the image. In an earlier post I explained how to produce such a title consisting of R objects and Greek letters.
I’ve attached the documentation of this plugin, first and foremost for me for cheating, but of course you’re allowed to use it also 😉
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.