Information about R (mostly for Windows)
This page is intended to provide undergraduates with information
about R (especially for Windows) which is common to the various
modules provided by the Department of Mathematical Sciences which make
use of R in one way or another.
The following topics are covered:
- Things relating to the Durham University Desktop Environment
(DUDE classroom and other PCs):
- Things relating to your own computer:
- General issues:
Accessing the durham library (and
other preinstalled libraries)
If you want to be easily to access the durham library (or
the many other libraries preinstalled on drive T: on CIS
computers):
- Open the Windows "explorer"
- Then navigate "Computer" -> T: -> MATHS -> R
- Double-click "Setup R for Maths".
If you already have R or Rstudio open, you should now close it and
reopen it. You should now be able to type library(durham)
without getting an error. There are many libraries pre-installed as
well (look in the folder where you found "Setup R for Maths").
Getting your own copy of R for
Windows
The best place to get your own copy of R for Windows is the
Comprehensive R Archive Network (CRAN) via the UK mirror of CRAN (the
latest version of R for Windows may be found in the Windows base
binary directory and older versions in the sub-directory
old).
You may install whichever version suits you but it may be wise to
install the same version as currently installed on the IT Service
networked PCs; otherwise any differences in behaviour are your problem
not ours!
- Download the setup program from the base
directory and run it to install R
- Read the README-R-?.?.? file in the base
directory to see if there any issues to do with installation or
initial usage.
- Note that data which has been provided especially for the
modules is not part of those zip files and you will need to
follow the instrructions below.
Ask me for help (via e-mail to P.S.Craig@durham.ac.uk)
if it doesn't work.
Getting your own copy of RStudio
We strongly recommend the use of RStudio as a front-end to R. First
install R and then visit the RStudio
download page.
Getting your own copy of the datasets used for
teaching at Durham
All (or at least most of) the datasets used for teaching with R in
the Department of Mathematical Sciences at Durham are in the R library
durham
- Windows
- To install this library on your own machine (having
first installed R using the instructions above), download the latest zip file (built with R 3.0.2 for
version 3.0.0 of R onwards) and put it on your hard disk. Then run R (for
Windows) on your machine and, from the Packages menu,
select Install package from local zip file. You only need
to repeat this operation if you download a new version. If the zip
file provided doesn't work and you have an older version of R then
try the previous version .
- MacOS X
- Download the latest MacOS
version(durham_1.4.tgz) and install from the local file by one
of the three following means:
- R Menu method
-
- Open R
- From the Packages & Data menu, open Package Installer
- In the combo box at the top of the new window, change it
from "CRAN (binaries)" to "Local binary package"
- Click Install... button, locate the file, click open.
- R command line method
-
- Open R
- Use getwd() and setwd() to make sure you are working in
the same directory as the package.
- install.packages("durham_1.3.tgz",repos=NULL)
- Terminal window method
-
In a terminal window, do
R CMD INSTALL durham_1.3.tgz
- Linux
- Download the latest
Linux version and save as a file. Then, in a terminal window,
do
R CMD INSTALL filename
Now you can access all the datasets in the usual way by typing
library(durham), and then, for example,
data(hospital) if you want the hospital data.
Remember that all the datasets have help files that you can access,
for example by typing ?hospital and that a list of
available datasets may be obtained by typing data()
Printing a plot
To print a copy of a plot, simply bring the R Graphics window
to the front and choose Print from the File menu.
Copying a plot to a Word document
Having produced a plot which is to your taste, you can save a copy of
it as part of (say) a Microsoft Word document and then you can print
the document. Proceed along the following lines:
- Bring the R Graphics window to the front.
- From the File menu choose the Copy to the
clipboard sub-menu and choose the as a Bitmap
item.
- If Word is not already running, go to the Windows NT Start icon
and open up a document; otherwise just switch to your Word
document window.
- Use the Paste item from the Edit menu to
paste the plot from the clipboard into the document at the point where
you want it to go.
Now you can do all the usual things with the Word document like add
explanatory text, save the document for future use, and
printing.
Peter
Craig
Last modified: Tue Oct 25 12:36:17 BST 2016