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):
- 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 dot.case.identifiers. 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.