Materials for the MOSAIC "Teaching Statistics with R and RStudio"
The content of each book is in a separate directory. That directory has a subdirectory, Master
with a file Master-*.Rnw
.
Each of the .Rnw
files in the content directory can be compiled on it's own. Just "Knit HTML" in RStudio. This will create a PDF file.
To create the whole book, you need to recompile each .Rnw
after setting a variable, notAsStandAlone=TRUE
. The process is
require(knitr)
# Change to the directory, e.g. 'Starting'
setwd("Starting") # go to your own directory
standAlone = TRUE
fnames <- list.files(pattern = "*.Rnw$") # files to recompile
for (fnm in fnames) knit(fnm)
This project consists of several short books that are inter-related.
- Start Teaching with R
Directory:
Starting
- The Core of a Traditional Course
Directory:
Traditional
- Simulation-Based Inference
Directory:
Simulation
- Functions and Formulas
Directory:
Functions
- Teaching with Internet Services
Directory:
Internet
- Start with Modeling
Directory:
Modeling
APPENDICES
A. Style instructions for authors B. Possible additional topics
Outlines for the individual chapters are in the Outline.Rmd
file in each directory.
Some general comments about the project as a whole.
Random list of things to include:
- RStudio introduction
- Packages and why to use them
- The mosaic package and others that we recommend
- Minimal R reference
- Rmd
- Umbrella for other books
- Error messages. Things to look for in error messages.
- overwriting names
- recycling vectors
- factors and characters
- Data
data()
- Group data with Google forms
fetchData()
and requesting a repository name- distributing other kinds of files, e.g. templates for .Rmd, scripts, ...
- Style
- Don't use one-letter names in your examples. Your students will pick this up and end up saying things like
c = makeFun(x~x)
, which will maskbase::c()
and mess everything up until youremove(c)
- Don't use one-letter names in your examples. Your students will pick this up and end up saying things like
Notes for the authors can be included using \authNote{A note to the authors.}
Processed notes for the authors can be hidden using \authNoted{A noted note to the authors.}
- R Code
- Use space after comma in argument lists
- No space around = in argument list
- Use space around operators,
<-
and->
- Casual comments (no need for caps)
- When referring to functions in the text, add empty parens (e.g.,
data()
) to make it clear that the object is a function.
- Exercises
N.B. Some exercises are for instructors, not for students.
- Use
\begin{problem} ... \end{problem}
to define problems. - Use
\begin{solution} ... \end{solution}
to define solutions.
- Use
This must be \emph{outside} the problem
environment and before the definition of the next problem. Put it immediately after \end{problem}
to avoid confusion.
-
Use
\shipoutProblems
to display all problems queued up since the lastshipoutProblems
. -
Examples Put within
\begin{example}
andend{example}
. We can tweak the formatting later. -
Marginal Notes We can place some marginal notes with:
\InstructorNote{This is an instructor note.}
\FoodForThought{We can tweak the layout, color, size, etc. later. For now. I'm just using color to distinguish.}
\Caution{This is a caution}
- Variable names. Often it's nice to distinguish between anactual variable name and a word that might have a similar name, for instance between sex and
sex
. Use the\VN{sex}
command to accomplish this. - Model formulas. Use
\model{A}{B+C}
to generateA ~ B+C
. Often, you may want to use variable names, for instance\model{\VN{height}}{\VN{age}+\VN{sex}}
givesheight ~ age + sex
.
The mosaic R-forge repository contains
- The
.Rnw
files - The dependencies in
bin/
- LaTeX dependencies in
inputs/
problems.sty
(for problems and solutions)authNote.sty
(for author notes)probstat.sty
(for some prob/stat macros)sfsect.sty
(for san serif section title fonts)
You may need to set an environment variable to make LaTeX look here.
- the
cache/
andfigures/
directories (so thatmake
can be used without complaint), but not their contents, which are generated bysweave
. - screenshots and other images not generated by
sweave
are inimages/
Do we want to include any of these topics?
- Fancier Lattice Graphics
- Base Graphics
- Making plots with
ggplots2
Only if one of us knows or wants to learn this system. - Writing executable R scripts
- R Infrastructure for Teaching Whatever of this we include might end up in the chapters rather than in an appendix.
- Sharing in R Studio
- Public Data
- Google Data
- Making Data Available Online
- A Brief Tour of knitr and R-markdown
- exams
- Books
- Our books
- Chance et al (in progress)
- Existing books that work well/poorly with R (and why)
- Online materials