Becky, and everyone:
You should create for each problem set two documents: "hw1.tex", and
"hw1.R", for example. The .tex document will include your LaTeX'ed
solutions to the problems, graphics, and any descriptive text. The .R
document will include the actual code you use to get the solutions.
Please don't dump every single line you enter into R into the .R document.
In other words, the answer to your last question is: "provide 'clean'
code". Also, commenting your code thoroughly will enable us to read your
work much more easily and will allow us to understand your intent should
you not get the correct solution. I've included an example of "commented"
code below. The example is somewhat over-commented to give you the idea.
Finally, the intent of the .R document is that your work can be entirely
replicated simply by typing source("hw1.R") at the R prompt. Thus, you
need to include *all* the commands required to obtain your answers,
including commands to load data, etc.
Let us know if you have any other questions!
Ryan
##Commented code:
##Below is a function that takes real numbers and prints them, then prints
##their natural logs. It's not too useful, but try it.
logprinter <- function(x){ ##x can be scalar or vector
y <- log(x) ##stores the log of x in "y"
print(x) ##the next two lines print x and log(x)
print(y)
} ##this is the end of my function
logprinter(1:4) ##letting 1,2,3,4 be the arguments
##[1] 1 2 3 4
##[1] 0.00000000000 0.69314718056 1.09861228867 1.38629436112
------------------------------------------
Ryan T. Moore ~ Government & Social Policy
Ph.D. Candidate ~ Harvard University
Homepage:
http://www.people.fas.harvard.edu/~rtmoore/
Gov1000:
http://www.courses.fas.harvard.edu/~gov1000/
Prefresher:
http://people.hmdc.harvard.edu/~mathpre/
On Wed, 29 Sep 2004, Rebecca Marie Nelson wrote:
Hi Alison,
Thanks for homework guidelines. I have a question about including R code
with our homework. I have been working on the problem set at a sort of ad
hoc basis, playing with lot of trial and error, doing parts as I know how
to do them and then going back to
other parts later. Thus, my R code pretty much becomes disorganized
quickly - but I
have been cutting and pasting my "successful" R code into the Latex
documents, following the code instructions in the hwtemplate.tex. Can
this
method (putting "clean" R code into the Latex document) fulfill the R code
requirement or do you still want a separate
print out of the R code? If so, do we need to present "clean" R code, or
can we turn in the mess we create when doing trial and error on the
problem sets?
Thanks,
Becky
_______________________________________________
gov1000-list mailing list
gov1000-list(a)lists.fas.harvard.edu
http://lists.fas.harvard.edu/mailman/listinfo/gov1000-list