When you do a homework, you must hand in three things
These can be submitted either
The write-up should be in plain English. It should explain whatever needs to be explained so that the instructor can understand what you did. The fact that your computer code is also being submitted is not an excuse for leaving it to the instructor to guess what parts of the code are relevant to what.
So say what you did and how. You may refer to the code, saying
my function bleat
does this and my function sally
does that. But you have to summarize your results and explain how you
got them.
You should provide one plain text file containing runnable R code
to produce all the results you mention in your write-up.
It would be nice for the grader if it is also fairly clean
in the sense that it doesn't also do a lot of irrelevant junk.
Suppose the plain text file is called foo.R
.
An example of such a file, which you can download and use for experiments is
Then under unix or mac OSX the unix command
R CMD BATCH --vanilla foo.R
will produce a file foo.Rout
containing all your results
with the exception that this is a plain text file and hence cannot
contain any plots (more on plots below). See the
on-line help for BATCH
for more details.
If the code generates random numbers, it should always generate
the same random numbers (so we know the computer actually
generated the numbers you report). To do this you need to set the
seed
of the random number with, for example,
set.seed(42)
before any random numbers are generated.
As the
on-line help for BATCH
explains,
the GUI device drivers are not available in BATCH mode.
What are available are the postscript
and
pdf
device drivers.
The command
postscript(file= "foo.ps")
will save all the plots subsequently made in the file "foo.ps".
Similarly, the command
pdf(file= "foo.pdf")
will save all the plots subsequently made in the file "foo.pdf".
If you don't like the way this device driver works with the default
arguments, there are a bazillion options that allow precise control
of everything, as the
on-line help for postscript
and the
on-line help for pdf
explain.
As with everything else. It's harder under Windows (TM).
Please read the section above about code under unix. Most of what we do under windows is similar. We just cover the differences between unix and Windows in this section.
First windows has weird newline characters. Download this example file
instead of foo.R
Then the unix BATCH command doesn't work. And the substitute provided by R doesn't work unless you also install Perl. What does work without installing anything else is to write a BAT file like the following
This can then be used as follows.
Download windoze.R
and Rbatch.bat
to the
same that folder on your computer. Get a Windows command line.
Change to that folder (directory) and execute the command
Rbatch windoze.R
Also Windows (TM), being fairly useless, has no way to display PostScript.
Hence you always want to use the pdf
device driver for
graphics.
The result of running your R CMD BATCH
command should be
one or two plain text files foo.Rout
and foo.ps
The result of running your R CMD BATCH
command should be
one or two plain text files foo.Rout
and foo.ps
depending on whether there are any plots.
The instructor's e-mail address is charlie@stat.umn.edu
.
If I know it is coming I will find it in amongst the spam.
Make the files foo.R
, foo.Rout
,
foo.ps
plain text attachments.
The plain text
is important. If you can't send plain text
in e-mail, you either need to learn how to use your mailer
or to get another mailer. If these files come as some kind of
proprietary garbage that can only be read if I buy another computer,
that is unacceptable. The best way to submit the write-up is for
you to simply print it out and hand it to me. The next best is
to attach to your e-mail a document in some readable format.
PDF (Adobe so-called portable
document format) is o. k.
Microsoft Word doc
format is o. k. so long as OpenOffice
can read it. I don't have Word and don't intend to get it.
OO can read most Word documents so long as they don't use
the latest and greatest customer enslavement features.
TeX formats are o. k. (.tex
, .dvi
, .ps
).
My computer has a floppy drive and a DVD drive, so it can read floppies or CD-RW or DVD-RW. Since it is linux, it can read most windows, linux, or mac formats.
The comments about file formats in the email section above go here too.
If you have a personal web site and don't mind letting the whole universe see your homework, you can just put the files on the web and tell me the URLs.
The comments about file formats in the email section above go here too.