0% found this document useful (0 votes)
44 views

Running R

The document provides instructions for installing and running R in Windows. It explains how to download and install R from the R-project website. It then describes how to install additional packages like DAAG and lme4 within the R environment. Finally, it outlines two methods for running R programs - in batch mode by running scripts from the command line or within the R workspace by using the R editor window.

Uploaded by

suprabhatt
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views

Running R

The document provides instructions for installing and running R in Windows. It explains how to download and install R from the R-project website. It then describes how to install additional packages like DAAG and lme4 within the R environment. Finally, it outlines two methods for running R programs - in batch mode by running scripts from the command line or within the R workspace by using the R editor window.

Uploaded by

suprabhatt
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

Running R in Windows

 Go to www.r-project.org

 Click on CRAN on the left-side on the screen under DOWNLOAD

 Scroll down the CRAN MIRROR SITES to a U.S. site (such as USA(NC))

 Under Download and Install R, select your operating system (Linux, MacOS-
X,Windows)

 Click on the link labeled base

 Click on the link for the current version (currently it is R-2.15.1). The current link for
Windows is: R-2.15.1-win32.exe

 Download R-2.11.1-win32.exe and install it on your computer

 After installation, open the R workspace environment and download the DAAG and lme4
packages:

o On the main toolbar click on Packages  Install Package(s)  Choose


USA(NC) as CRAN Mirror  Select DAAG

o Repeat process for lme4

 You may run programs in interactive mode in RGui environment, but I will not support
this approach for this course, I will give all programs and suggest you run the programs
in batch mode.

Running programs in batch mode

Assumptions (make any necessary changes to directories):

A. You have the file Rterm installed in directory C:\Program Files\R\R-


2.15.1\bin\
B. You will keep and run all programs in the directory (where XXXX is your course
number) C:\staXXXX\

C. You will keep and run all data in the directory


C:\data\

Step 1: Create a batch file in the directory you will be running R from

In any text editor, create a one line program R.bat with the text (those are 2 “-“ signs before vanilla):

C:\Progra~1\R\R-2.15.1\bin\Rterm --vanilla

(Note: This will only have to be done once)

Step 2: Write your program (or download one)

In any text editor, type or edit an existing program (say progtest.r)

Begin program with the line (this will send any graphics output to a pdf file):

pdf(“progtest.pdf”)

End program with the line:

dev.off()

Step 3: Run your program

Pull up the Command Prompt under Accessories in Windows

Change to the directory with your program:

chdir staXXXX

Give the command to run your program:

R <progtest.r> progtest.out

Any text output will be written to the file progtest.out which can be input to WORD, notepad, etc.
Running programs in the R Workspace

 Open R (Double Click on Desktop Icon or Open Program from START)

 Click on File → Open Script

 Select the Program you want to run, it will appear in a R Editor Window

 Right Click Select All (or Type Ctrl-A)

 Right Click Run Line or Selection (or Type Ctrl-R)

 Output will appear in R Console Window

 Graphics will be routed to file you create in pdf statement

You might also like