Jeromy Anglim's Blog: Psychology and Statistics

Thursday, October 29, 2009

Tips for Using StatET and Eclipse for Data Analysis in R

My favourite editor for conducting analysis in R is the StatET plug-in for Eclipse. This post discusses an assortment of tips and tricks that I've discovered to make this editing environment even better.

  • Search (Control + H): I maintain projects in the project explorer. If I need to know how I have used an R function in the past, I search for the function name.
Options for Running R Code
  • List Run Options (Control + R)
  • Run entire command (Control + R Control + E): Press this key combination on the identifier for a function to run entire function (particularly useful for running nested functions). It's also useful when you have a line of code that spans multiple lines.
  • Run Function Definition (Control + R Control + F): Fun function definition; If you have nested functions, this key combination runs the both outer and inner functions. Thus, don't use this to refresh the function definition of a nested function.

    • Fix Indentation  (Control + I)
    • Delete Line (Control + D)
    • Code Folding

      • Expand Current: (Control + Num "+")
      • Collapse Current (Control + Num "-")
      • Collapse All (Control + Shift + Num "/")
      • Expand All (Control + Num "*")
      • Enable/Disable Code Folding (Control + Num "/")
    • List tips and tricks (Help - Tips And Tricks - Eclipse Platform)
    • View all short cut keys (Control + Shift + L):
    Outline View
    • Highlight Outline (Alt + Shift Q, O)
    • Refresh code in a function (right click on function in Outline)
    • Cut and paste functions (Use Outline View)

      • Get file path (Alt W, V, P, P, Enter; Navigate to file; Alt + Enter; Alt + L; Shift + End; Shift + Down; Control + c)
      • Go to function definition (Copy function name; Control + Tab to go to function sheet; control + home to go to top of function sheet; control + F to find; control + v to paste; Enter; Esc)
      • Activate cursor in console (Control + R, C)
      • Activate cursor in editor (F12)
      • Toggle maximisation of current window (Control + M)
      • Auto completion (Control + /); this does not worke with Thus, this is another reason to prefer mixedCaseIdentifiers.
      • Print current variable (Control + R, P); this is useful when writing functions; I might run an assignment (control + R, control + R) and then print the result. However, it is problematic when there is a lot of data.
      • Change variable names (Control + 1)
      • Opening Files in Project Editor based on standard file association (Right Click File - Open With - System Editor). Many files will open within StatET. This is sometimes undesirable.


      1. Thanks for writing this post!

      2. Great post.
        Another favorite of mine: F3
        Automatically opens the function definition for custom functions, when your cursor is on that function name.

      3. Hi, I see all the folding shortcuts that you mentioned above, but how can you fold a chunk of code in StatET? I can't find anything after right-clicking on a selected chunk of code, neither do I find a button for doing this. Any advice is appreciated.

        1. Hi Moe, I wrote this post a few years ago. I use RStudio and Vim these days. So, sorry, I can't really help you. Perhaps try stackoverflow with the R tag.