Running r in Windows



Download 10.84 Kb.
Date09.06.2018
Size10.84 Kb.
#54066
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:

    • On the main toolbar click on PackagesInstall Package(s)  Choose USA(NC) as CRAN Mirror  Select DAAG

    • 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):

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

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

  3. 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.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


Download 10.84 Kb.

Share with your friends:




The database is protected by copyright ©ininet.org 2024
send message

    Main page