A simple example of a statistical analysis using R2wd

The document is an R script. Special commands provided in the R2wd package push output into a Word file.

wdTitle("Simple R2wd usage example")
wdTitle("Analysis of Fisher's iris data")
wdTitle("BERD Reproducible Research working group")

# load data
"The famous (Fisher's or Anderson's) iris data set gives the measurements in centimeters of the variables sepal length and width, and petal length and width, respectively, for %d flowers from each of %d species of iris. The species are %s.", 
table(iris$Species)[1], nlevels(iris$Species), paste(levels(iris$Species), collapse=", ")))

wdBody("First, let's run a simple ANOVA comparing the sepal lengths of the three species.")
a1 <- aov(Sepal.Length~Species, data=iris)
wdTable(round(summary(a1)[[1]],3), caption=": ANOVA table")

wdBody("We can see that the three species have significantly different sepal lengths. Figure 1 shows the corresponding boxplot.")

wdPlot(Sepal.Length~Species, data=iris, ylab="Sepal length", plotfun=boxplot, width=4, height=4)
This file has to be evaluated by R using source() or copy-paste. This produces the following Output file .

-- AnikoSzabo - 30 Dec 2010

Topic attachments
I Attachment Action Size Date Who Comment
iris.RR iris.R manage 1 K 30 Dec 2010 - 21:22 UnknownUser R script using R2wd to create reprodicible Word report
iris.docxdocx iris.docx manage 415 K 03 Oct 2014 - 20:58 UnknownUser Output of R2wd script iris.R
iris.pdfpdf iris.pdf manage 415 K 03 Oct 2014 - 21:02 UnknownUser Output of R2wd script