Giter Club home page Giter Club logo

rtools's Introduction

Rtools for Sublime Text 2

This package provides a couple of useful tools for people using Sublime Text 2 to code in R. It has the key bindings to send a selection of code to R, and can also generate Roxygen documentation templates for any function quickly (select first line of a function till the first {, press keybinding and it will generate a template with @params from the function definition).

We plan to add functionality of formatR so you can format/tidy code inline to the next version. Please suggest other feature requests as issues (preferably tagged as a feature request).

Installation

Installing via Package Control: The fastest way to install is via the command palette (open command palette, type in Install Packages, and once list is populated look for R tools)

If you don't have package control installed, the just clone this repo into your Sublime Text 2/packages directory

git clone [email protected]:karthikram/Rtools.git

Customization

  1. Since I am on OSX and use R64.app, I have set it up that way. If you prefer to use 32-bit R, replace R64 with R in the Rtools.py file. In windows (untested), you should set it to the R.exe file you wish to use.

  2. I have included a basic roxygen template to populate the section above each file. If you prefer to have fewer or more fields, I will move it to a settings file in a future version. For you you can edit Rtools.py or post it as an issue and I will update it.

Key bindings

To preserve or change these key bindings, copy them to your Key Bindings - User file.

rtools's People

Contributors

acjackman avatar jlegewie avatar karthik avatar rodrigorgs avatar wch avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rtools's Issues

Auto-completion for R (R.sublime-completion file)

Hi,
I am not sure how auto completions work for you but I create a R.sublime-completions file at one point. Here is a description:

http://readthedocs.org/docs/sublime-text-unofficial-documentation/en/latest/extensibility/completions.html?highlight=sublime-completions

So the auto completions come from different sources. One is the sublime-completions file. Check out my R.sublime-completions to see whether such a file improves the auto-complete proposals ST2 makes. I can't really tell whether it makes a difference because it's to long ago that I added this file. Here it is (I think you just have to put it in your packages/R folder:

https://gist.github.com/2336626

Note that this file includes functions that are particular to my packages and my own functions. So it will make suggestions that do not make sense for you occasionally. If such the sublime-completions file improves auto-completion for R, I can send you code for the Rtools package that automatically creates a auto-completion based on the currently loaded packages in R. It's not going to be straight forward to integrate this code in the ST2 package but it would be possible to create a R.sublime-completions for the base and some popular R packages or invest some time to integrate the automatic creation of the file in Rtools.

Using Rtools in Windows

Are there step by step instructions for how to get this to work on windows? I tried changing the R64 to R.exe in the Rtools.py file but it still didn't work. I also changed the key bindings to something more windows friendly, but it still didn't work. Any suggestions?

Cmd+b conflicts with the default keybinding for "build"

Cmd+B ("super+b") conflicts with the default keybinding for "build". See the file Packages/Default/Default (OSX).sublime-keymap:

{ "keys": ["super+b"], "command": "build" },

The recent change breaks the default keybinding. It took me a while to track the culprit to R Tools. Maybe it would be possible to setup a build system for R so that "build" command either launches R in batch mode, or sources the current file in the R GUI?

ST2 function tooltip for R

Hi,

building on my last issue, the actual goal is to have function tooltip as shown here for Notepad++ (second screenshot):
http://yihui.name/en/2010/08/auto-completion-in-notepad-for-r-script/

That would really be useful but the current ST2 architecture only offers limited ways to do that. Take a look at this thread for a discussion about that:
http://www.sublimetext.com/forum/viewtopic.php?f=2&t=2670
and you can also cote for the issue here:
http://sublimetext.userecho.com/topic/54838-/

As long as ST2 does not support tooltips, a workaround would be to put the function help in the status bar. SublimeCodeintel does that for some languages. I think that the content of the tooltips can be automatically generated from R and saved in a json file (based on the script of the completion file I mentioned in the other issue). For example, for rnorm the tooltip should look like
rnorm(n, mean = 0, sd = 1)
to show the arguments and the default values.

If you are interested in working on this, I could cover the R side (i.e. automatically generate the json file with the tool tips). Maybe there is also a better way to achieve this...

RTools for ST3

I just upgraded to ST3, but unfortunately, RTools doesn't seem to send R code to the R (3.0.0) window as it does in ST2. I wonder if there's a quick workaround for this.

Compile Rmd file using knitr

Great tool! Thanks for creating this. I am a long-time macvim user just moving over to SE2. Your Rtools package is making the transition a lot smoother for me.

I'd luv to be able to compile Rmd files as well. The following works on mac as a 'build-system'. Issue is it opens a new tab/browser each time you recompile. Is this still something you are working on?

"cmd": ["osascript", "-e", "tell app "R64" to cmd "file <- '$file'; knit2html(file); browseURL(sub('.Rmd','.html',basename(file)))"\n"]

Roxygen generator clarification

According to the doucmentation: "...select first line of a function till the first {, press keybinding and it will generate a template with @params from the function definition..."

which keybinding? Could you make it more clear exactly what is required to get this to work?

Allow communicating with other R sessions

I usually use R from the terminal, and run multiple sessions at once. It would be nice to be able to:

  • "Connect" an ST window to any given instance of R. This could be done by finding the process id of an R instance with Sys.getpid(), and somehow give the ST Rtools plugin that pid.
  • Set a default R process that ST sends commands to. This is the R process that ST sends commands to, unless otherwise specified. The default default could be the R instance with the lowest-numbered pid. It should also be possible to change the default.

R-build system not being picked up automatically

To get the build-system from R-tools to be selected automatically I had to add a 2nd line to the R.sublime-build file

{
"cmd": ["osascript", "-e", "tell app "R64" to cmd "source('$file')"\n"],
"selector": "source.r"
}

ST2 linter for R

Hi,

here is another suggestions for a possible future feature. Not sure whether my thoughts on an actual implementation are reasonable. Note that this would actually extend SublimeLinter (https://github.com/Kronuz/SublimeLinter) and not Rtools.

Here is how I think it could work:

  1. The R package 'svTools' provides a lint function.
  2. rpy2 provides a python interface to R (http://rpy.sourceforge.net/rpy2.html) so that it should be possible to call the lint function from python and work with the output.
  3. The steps to add new languages to SublimeLinter are described on the bottom of this page: https://github.com/Kronuz/SublimeLinter

EDIT: Simple example

    require(svTools)
    # no lint warning
    lint(text="summary(rnorm(100))")
    # lint warning for additional )
    lint(text="summary(rnorm(100)))")
    # output:
    # line column        message  type
    #4    1      1 unexpected ')' error

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.