create new tag
, view all tags, tagging instructions

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
elseR iris.R manage 1.9 K 30 Dec 2010 - 15:22 AnikoSzabo R script using R2wd to create reprodicible Word report
elsedocx iris.docx manage 415.4 K 03 Oct 2014 - 15:58 MaryBanach Output of R2wd script iris.R
pdfpdf iris.pdf manage 415.4 K 03 Oct 2014 - 16:02 MaryBanach Output of R2wd script
Topic revision: r2 - 03 Oct 2014 - 16:03:53 - MaryBanach

Copyright & by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding CTSPedia? Send feedback