R is a powerful statistical programming language widely used for data analysis, visualization, and statistical modeling. In this article, we will explore how to interact with R interactively, both on UNIX and Windows systems.
Getting Started on UNIX
Setting Up Your Workspace
The first step in using R on UNIX is to create a dedicated sub-directory to organize your work and data files. Let's name this directory "work."
$ mkdir work
$ cd work
This directory will serve as your working directory whenever you use R for a specific problem.
Launching R
To start the R program, use the following command in your UNIX terminal:
$ R
After entering this command, you will see the R prompt, indicated by the default symbol '>.' This is where you can enter R commands.
Working with R
Now that you are in the R environment, you can issue commands and perform data analysis. For example, you might load data, manipulate variables, or create visualizations using R functions.
To quit the R program, use the following command:
R
> q()
Upon quitting, you will be prompted to save your data. Choose whether to save or discard your session based on your preferences.
Subsequent Sessions
For future R sessions on UNIX, follow these steps:
1. Navigate to your working directory:
$ cd work
2. Launch R:
$ R
Repeat this process for each session, making sure to save your data when prompted.
Working with R on Windows
Using R on Windows follows a similar process with a few minor differences.
Setting Up Your Workspace
Create a folder to serve as your working directory. Set this directory in the "Start In" field of your R shortcut to ensure R knows where to look for your files.
Launching R
Double-click on the R icon to launch the program.
Subsequent Sessions
For future R sessions on Windows, simply double-click the R icon again, and you'll be ready to start a new session.