Tinn-R Install and Usage
Tinn-R Install and Usage
Tinn-R Install and Usage
text editor for MS Windows that helps writing codes for several software using a command line interface such as R. It communicates with the graphical user interfaces (GUI) of R. When analysing data, you can use Tinn-R to type commands and send them to R. The result will appear in R's Rconsole or Tinn-R's Rterm interface. Tinn-R has many useful features like syntax highlighting (i.e. using different colours for commands, parentheses or objects), numbering command lines and highlighting the active line. These help users to find their way easily when using R. Tinn-R allows organizing files into projects and creating shortcuts to favourite folders. It also includes a Reference Card for R. Tinn-R has many more features not detailed here. The newest release of Tinn-R can be downloaded from https://sourceforge.net/projects/tinn-r. You can download R from http://cran.at.r-project.org/ I. Settings within R: 1. R should be set in SDI mode (separate windows MDI: one big window) to communicate with Tinn-R. If you just start installing R, at Startup options choose Yes (customized setup), then at the next step Display mode choose SDI (separate windows). Accept defaults at all other settings. If R has already been installed on your computer, check window status by reading the file
C:/Program Files/R/R-2.8.0/etc/Rconsole Rconsole can
# Style # This can be 'yes' (for MDI) or 'no' (for SDI). # MDI = yes MDI = no
Note that in R the symbol # means that the following text is a remark until the end of the line. Therefore, all lines beginning without # are commands. You can use this symbol throughout your work eihter typing it to Rconsole or to Tinn-R for adding remarks to your scripts. 2. R can be customized after installation by changing the file Rprofile.site e.g. with Notepad. You can find it where you have installed R on your computer, e.g.
C:/Program Files/R/R-2.8.0/etc/Rprofile.site ,
it can be opened & changed & and serves for personal settings of R, e.g. for automatically loading packages or functions when opening R. This is very useful when installing a new version of R: you just have to copy this file from the etc folder of the old version to that of the new one, and given that you have internet connection, the new version downloads and installs 1
all the required packages at the first restart. A sample profile can be found at http://www.univet.hu/users/jkis/education/Statisztika_gyakorlat/Rprofile_example.txt II. Settings within Tinn-R: 1. If R has been installed on your computer before Tinn-R, Tinn-R usually finds it automatically. Otherwise, e.g. when you install a new version of R, you may have to set the path where R has been installed, specific to your computer, by clicking on 'Path of your preferred Rgui' under
Options > Main > Application > R > General: Rgui {parameters and path}
or
Options > Application > R /Path: Rgui {Parameters and path (Gui)}
Click on Path of your preferred Rgui, then set the path, e.g. C:/Program Files/R/R-2.7.2/bin, then select an R-GUI. Tinn-R communicates well e.g. with Rgui.exe or Rterm.exe. Rgui uses the Rconsole, while Rterm uses its own window. In contrast to Rgui, Rterm uses syntax highlighting. If both are active, Tinn-R focuses on Rterm. To make them active/inactive, select
R > Start/Close and connections > Rterm () > Rgui ().
2. You can split the screen between Tinn-R and Rconsole by selecting
Options > Main > Application > R > Organize
or
Options > Application > R /General /Rgui
or
Options > Editor > Display > gutter: line numbers
4. For proper syntax highlighting, you need to set Tinn-R to apply the language of the software commanded, e.g. R-complex for R:
Options > Syntax > Set: R-complex
5. Tinn-R allows using shortcut key combinations for sending commands to R. These shortcuts have to be set by the user under
R > Controlling R > Hotkeys of R (system)
This part from Tinn-R 2.0.0.1 was completely reworked. In order to make it working, you should select
This command will read the Rprofile.site (path probably C:/Program Files/R/R-2.8.0/etc/), close R & complete it under section # Tinn-R: necessary packages and functions with something like the following:
.trPaths <- paste(paste(Sys.getenv('APPDATA'), '\\Tinn-R\\tmp\\', sep=''), c('', 'search.txt', 'objects.txt', 'file.r', 'selection.r', 'block.r', 'lines.r'), sep='')
You should save this file and restart R. Then set hotkeys for selections where (echo=T):
R > Hotkeys of R (operational system). F5 for send: line & Ctrl F5 for send: selection (echo=T) is recommended, same shortcuts. Do not forget to switch to active mode.
6. Under R > Controlling, you can find many useful tools such as clearing the Rconsole or closing graphic windows with shortcut keys. Do not hesitate to try them. III. Organise your files into project in Tinn-R: Tinn-R lets you organise your data files, R-code scripts, new files created during an R-session such as summary tables, etc. into projects. Tinn-R associates these files to user-defined virtual folders called groups by creating a text-file with the extension .tps. This text file gives the linkstructure and the paths of all included files. Thus with opening the .tps file, you can see and access all the files in a project. Instead of keeping in mind, which file is a data file and which one is a summary table or just a detailed description of the methods to measure the variables you use in your analyses, you can associate the appropriate files to groups for each of these categories. TinnR will not produce copies of your files, so it will not increase disk space significantly. 1. To create a new project, select
Project > New
from the menu and save it in the working directory for your R-session (or wherever you want). This will create a .tps file and open a tool panel similar to Fig. 1. To hide or call this panel, press
View > Tools > Tools (Show/Hide) or Ctrl /
or
View > Tools > Tools (Show/Hide) or Ctrl F8
First, only one green box, the generic group will appear under your .tps folder. 2. To create a new group, select
Project > Group(s) > New.
3. To associate a file to a group, first click on a group in the tool panel, then select from the menu bar
Project > File(s) > Add.
4. If you work on different computers and want to transfer your projects from one to the other, you may have different paths and have to change the project structure. This is very simple: choose
Project > Edit (as text file).
This will open the text file in which you can change the paths by the replace function:
Search > Replace.
5. Once changes are saved, the project should be reloaded from the .tps file:
Project > Reload (from text file).
Fig. 1. Tinn-R project in the tool panel and editing the project as text.