R for Linux
"R is a free software environment for statistical computing and graphics," as provided through The R Project. R is a principal data analysis tool in the emerging field of data science, and is more central to this effort than SAS, Stata or SPSS. R is provided in Enterprise Linux and is available on Sociology compute servers. It is updated by new releases through the Enterprise Linux upstream provider.
R runs in the following modes:
RStudio Integrated Desktop Environment (IDE) from a secure web browser connection
Command Line from a terminal window
Grapical Command Line from an X11 window
Batch Submission from a terminal command line
1. RStudio IDE
- Two RStudio instances are available on servers charisma and paradigm. Charisma is the more powerful and recommended server.
- Authenticate with your Duke NetID credentials.
- When the RStudio login screen appears, authenticate with your Duke Sociology credentials.
- The RStudio desktop appears upon login.
Click Sign Out to end your session.
2. Command Line Mode
- Open an SSH terminal connection, with X11 support if you anticipate needing to display graphical output.
Type R at the command line prompt to open an R session.
Type q() to quit the session.
3. Graphical Command Line Mode
- Open an SSH terminal connection, with graphical X11 support
Type R -g TK & at the command line prompt to open an R session in a separate X11 window.
4. Batch Submission Mode
- Open an SSH terminal connection.
- Edit R programs with your preferred editor (vi, emacs, pico).
Submit an R job from the command line prompt with R CMD BATCH <program_file>.R &, where <program_file>.R is the name of the R code file.
- The R job runs to completion in the background.
5. R Packages
There are thousands of user-contributed R packages. The primary package repository is the Comprehensive R Archive Network (CRAN). Packages are add-ons to the base installation of R.
Installation of a package may be global and available to all users. Or a package can be installed by a user under their home directory making it only available to that individual. Because a package needed by one user is often needed by others, global installation is generally the best practice. Send package requests to Bob Jackson.
When a new release of R is installed, packages are also checked for available updates.
The library() command provides a list of currently installed packages.