This is the only page on my website in English so far, but the German Tinn-R page is visited quite often, so I thought a translation would help people around the world.
Anything unclear? Any grammar mistakes? Thankful for this information here?
–> Leave a comment below!

clickable overview:
1. connect Tinn-R with R
2. Be able to send several rows to R at once
3. Get started
4. Shortcuts and helpful Tinn-R settings
5. Permanent Tinn-R and R windows layout via Rconsole
6. Why I like Tinn-R better than R-Studio

For comfortable programming, you should write your code in scripts with an editor. I like to use Tinn-R, but nowadays I recommend R-Studio (growing popular since February 2011). The advantages of Tinn-R: control about window layout, nice syntax highlighting, own shortcuts and bookmarks. It only runs under Microsoft Windows, though.


.

1. Connect Tinn-R with R

start R

start R

When you first click on the start button, you should have to set the connections to Rgui and Rterm.
Set those to C:\Program Files\R\R-3.3.1\bin\x64\Rgui.exe or wherever you installed R.
You can also do this later under Options – Application – R – Path.

To the top


.

2. Be able to send several rows to R at once
Older versions of Tinn-R can by default not send several lines (until the next empy line) at once, which you want to do with R send: contiguous. Instead you get an error message like Error in source(.trPaths[5], echo = TRUE, max.deparse.length = 150) : object ‚.trPaths‘ not found.
In versions since 2015, I disable the tinnRcom and svSocket packages because it prolonges the startup time and I don’t use completion that much anyways. TinnR – options – Application – R – Packages (unselect all three checkboxes) and in R – Basic unselect „set R environment“.
Create the object .trPaths :

.trPaths <- paste(Sys.getenv('LOCALAPPDATA'),
'\\Temp\\Tinn-R', c('', 'search.txt', 'objects.txt',
'file.r', 'selection.r', 'block.r','lines.r'),sep='\\') 

If you write this in your equivalent of C:\Program Files\R\R-3.3.1\etc\Rprofile.site, R will create the object automatically, and you never have to worry about it again. R reads and executes everything in Rprofile.site (Linux: .Rprofile) at startup. For windows 7, you have to relax the write protection settings of the folder C:\Program Files\R and give the user the rights to change files beforehand.
Things in Rprofile overwrite objects in base, so be careful!
Read on here about the nice things you can write into Rprofile.

To the top


.

3. Get started
File > new and R > start > Rgui (or quicker with the start button mentioned in section 1).

To the top


.

4. Tipps and keyboard shortcuts
Options -> Return Focus to Editor (on), so you can send lines to R with your keyboard, and then continue to write without selecting the window into the foreground again (window focus).
View -> Line Numbers (Show), so you can see how many blank lines are at the end of the file, click there with the mouse and add more code. And to be able to tell others „in line 316, you…“

personal keyboard shortcuts
Tinn-R Options -> Shortcuts: Group „R send“ Caption „Line“
Shortcut: eg. CTRL + „/“ then click Save, then Close.
I also set „Send Selection (echo=T)“ to CTRL+“.“ and „send contiguous(echo=T)“ to CTRL+“,“.

default shortcuts

Shortcut Action
CTRL + F find words in the script, continue with F3
CTRL + R search and replace
CTRL + 9 writes „( )“ and puts the cursor in the middle
CTRL + C / X / V copy / cut / paste
Pos1 / End line beginning / end
CTRL + Pos1 / End script beginning / end
CTRL + B If the cursor is at the left of a bracket, it is set to the bracket’s counterpart.
CTRL + D arguments of the function, e.g. „write.table(„, then press CTRL+D. Not available for all functions…
CTRL + Z undo
CTRL + SHIFT + Z redo
F1 calls the (html)help for the command at the cursor. For function.part (with dot), mark the complete function before pressing F1.
F2 structure of the object, at which the cursor is blinking
F11 deletes all objects in the workspace, see ?rm. F12 also closes graphic windows.
Ctrl + Shift + [0-9] set a bookmark (upper numbers, not with the number pad)
Ctrl + [0-9] go to a bookmark

and more, see PDF Tinn-R User Guide and the current version of the Tinn R manual (Tinn-R eBook_RII.pdf).
At R – Hotkeys (Operational System) – Custom, you can define awesome things like:

View(selection); summary(); head(); tail(); dim(); class()

To the top


.

5. Tinn-R and R windows layout
Tinn-R versions since the fall of 2012 set the window position from the last session at startup. For windows XP: Options – Application – R – Rgui – Options (Rgui) r clear the checkbox „Organize automatically“. In case graphics are opened in the R console (SDI was not selected at installation), set MDI=no in the file Rconsole (see below)

Tinn-R opens the R Console as specified in C:\Program Files\R\R-3.3.1\etc\Rconsole (or wherever R is installed). The position and size on the monitor can be set like this (for my 22 inch monitor with HD resolution 1920 x 1080):

# Dimensions (in characters) of the console.
rows = 15
columns = 100
# Dimensions (in characters) of the internal pager.
pgrows = 15
pgcolumns = 100
# Initial position of the console (pixels, relative to the workspace for MDI)
xconsole = 1088
yconsole = 716
# experiment with the values to satisfy your own taste! 

See details for changing the file in section2

For my 15″ Laptop with 1280*800 resolution I have MDI = no, rows = 12, columns = 62, xconsole = 757, yconsole = 493, xgraphics = -5, ygraphics = 0.
In Rprofile.site I also wrote grDevices::windows.options(width=5.4, height=4.4). This is what it looks like:
R_Anordnung

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

mReg is available here.
To the top


.

6. Comparison of editors

Tinn-R has the following advantages compared to R-Studio:

The Syntax-Highlighting marks function names independent of the „(“ behind it, so you’ll find typos quickly.
You can very flexibly arrange each window (editor, console, View, graphic device, rgl device etc.), this is especially helpful on two monitors. But it needs some tweaking for optimal comfort and defaults (see section 5 above).

Sending from current line to the next empty line, even with personal keyboard shortcuts is possible.

You can set bookmarks.

With one single click on the working directory icon, you can setwd to the folder with the current script (which is also done when you start R from Tinn-R).

In the (browser HTML-) help, you can follow a link and get back to the last page with the „back“ button of a 5-button-mouse.

The vertical line at column 80 is shown by default, reminding you to write readable code with lots of newlines so you don’t have to scroll horizontally. Update: In Rstudio, you can turn it on via Tools – global options – Code – Display – Show margin

———————————————————————–

Tinn-R has the disadvantage to only run under Windows.

To get to the help page of dot-separated functions like help.start by pressing F1, you first have to select the full function name. R-Studio does not separate words at dots.

R-Studio automatically adds the closing bracket and quotation marks. Also, within functions, the indent after pressing return is nicer than in Tinn-R (which indents only based on the preceding line).

R-studios built-in support of knitting documents as well as writing and testing packages is amazing!

Rstudio open help documentation in browser:
This thread has a solution. On Windows, I find the file under C:\Program Files\RStudio\R.

Go to http://sciviews.org/_rgui for a full list of editors. Also, use your favorite search engine for finding posts and discussions in forums and mailing lists on the large topic of editor and GUI.

In the end, choosing an editor is a matter of taste…

Any other pros and cons are very welcome in the comments below!

To the top

2 Antworten to “Tinn-R (english version)”


  1. 1 Joe 15. Dezember 2015 um 20:00

    It’s worth pointing out that RStudio has been developing quite well over the years, and a few of the disadvantages you list are no longer true:

    1. RStudio supports find-and-replace within a selection
    2. RStudio can display a vertical margin at a width you select, but you have to turn the feature on in the settings (Tools -> Global Options -> Code -> Display -> Show margin). Moreover, it now includes a „reformat code“ function (that you must call from the menu or a keyboard shortcut) that will break up long lines and adjust indentation to create „tidy“ code.
    3. You can double-click on a word to select it and then move or replace it
    4. Though it does not support bookmarks, the code sections, folding, and „jump to“ features can provide some similar (though I admit far from equivalent!) benefits to workflows

    I do hate the limited customizability of the 4-pane view (which might never change because I’m guessing it’s tied to the browser-based interface). They just keep adding and polishing features so well and so often that I can’t imagine any other editor keeping up.

  2. 2 Berry 16. Dezember 2015 um 14:05

    You’re absolutely correct, thanks for pointing that out. I updated the page accordingly and also hinted at Rstudio being much better for package development and creating documents.


Hinterlasse einen Kommentar