This is a quick set of analyses of the California Test Score dataset. The post was produced using R Markdown in RStudio 0.96. The main purpose of this post is to provide a case study of using R Markdown to prepare a quick reproducible report. It provides examples of using plots, output, in-line R code, and markdown. The post is designed to be read along side the R Markdown source code, which is available as a gist on github.
- R Markdown Formatting Guide
- Learn R Markdown
- R Markdown Definitive Guide
- R Markdown The Definitive Guide
Make them all ordered lists 1. Tagspaces ug. Do something else. If the reverse-Pi separation gauge is set to `OFF` you can follow the following procedure. Use the flux capacitor on Mondays. Read the full Easy Markdown Online User Guide. TRY BEFORE BUY - FREE DOWNLOAD. You can download the application from our site and full test it.
Preliminaries
- This post builds on my earlier post which provided a guide for Getting Started with R Markdown, knitr, and RStudio 0.96
- The dataset analysed comes from the
AER
package which is an accompaniment to the book Applied Econometrics with R written by Christian Kleiber and Achim Zeileis.
Load packages and data
Q 1 What does the CASchools dataset involve?
Quoting the help (i.e., ?CASchools
), the data is “from all 420 K-6 and K-8 districts in California with data available for 1998 and 1999” and the variables are:
Let's look at the basic structure of the data frame. i.e., the number of observations and the types of values:
Q. 2 To what extent does expenditure per student vary?
The greatest expenditure per student is around double that of the least expenditure per student.
Q. 3a What predicts expenditure per student?
R Markdown Formatting Guide
More is spent per student in schools :
- where people with greater incomes live
- reading scores are higher
- that are K-6
Q. 4 what is the relationship between district level maths and reading scores?
At the district level, the correlation is very strong (r = The correlation is 0.92
). From prior experience I'd expect correlations at the individual-level in the .3 to .6 range. Thus, these results are consistent with group-level relationships being much larger than individual-level relationships.
Q. 5 What is the relationship between maths and reading after partialling out other effects?
The partial correlation is still very strong but is substantially reduced.
Q. 6 What fraction of a computer does each student have?
The mean number of computers per student is 0.136
.
Q. 7 What is a good model of the combined effect of other variables on academic performance (i.e., math and read)?
pairs.panels
shows correlations in the upper triangle, scatterplots in the lower triangle, and variable names and distributions on the main diagonal.
After examining the plot several ideas emerge.
Normally, I'd add all these transformations to an initial data transformation file that I call in the first block, but for the sake of the narrative, I'll leave them here.
Let's examine correlations between predictors and outcome.
Let's examine the multiple regression.
And some indicators of predictor relative importance.
Thus, we can conclude that:
- Income and indicators of income (e.g., low levels of lunch vouchers) are the two main predictors. Thus, schools with greater average income tend to have better student performance.
- Schools with more computers per student have better student performance.
- Schools with fewer students per teacher have better student performance.
For more information about relative importance and the relaimpo
package measures check out Ulrike Grömping's website.
Of course this is all observational data with the usual caveats regarding causal interpretation.

Now, let's look at some weird stuff.
Q. 8.1 What are common words in Californian School names?
The word “Elementary” appears in almost all school names (98.3
%). The word “Union” appears in around half (43.3
%).
Other common words pertain to:
- Directions (e.g., South, West),
- Features of the environment (e.g., Creek, Vista, View, Valley)
- Spanish words (e.g., rio for river; san for saint)
Q. 8.2 Is the number of letters in the school's name related to academic performance?
Learn R Markdown
The answer appears to be “no”.
Q. 8.3 Is the number of words in the school name related to academic performance?
The answer appears to be “no”.
Q. 8.4 Are schools with nice popular nature words in their name doing better academically?
So we've found a small correlation.
Let's graph the data to see what it means:
So in the sample nature schools have slightly better reading score (and if we were to graph it, maths scores). However, the number of schools having nature names is actually somewhat small (n= 61
) despite the overall quite large sample size.
R Markdown Definitive Guide
But is it statistically significant?
So, the p-value is less than .05 for reading (p = 0.046
) but not quite for maths (p = 0.083
). Bingo! After a little bit of data fishing we have found that reading scores are “significantly” greater for those schools with the listed nature names.
But wait: I've asked three separate exploratory questions or perhaps six if we take maths into account.
- $frac{.05}{3} =$
0.0167
- $frac{.05}{6} =$
0.0083
At these Bonferonni corrected p-values, the result is non-significant. Oh well…

Review
R Markdown The Definitive Guide
Anyway, the aim of this post was not to make profound statements about California schools. Rather the aim was to show how easy it is to produce quick reproducible reports with R Markdown. If you haven't already, you may want to open up the R Markdown file used to produce this post in RStudio, and compile the report yourself. Elab driver download.
In particular, I can see R Markdown being my tool of choice for:
- Blog posts
- Posts to StackExchange sites
- Materials for training workshops
- Short consulting reports, and
- Exploratory analyses as part of a larger project.
The real question is how far I can push Markdown before I start to miss the control of LaTeX. Markdown does permit arbitrary HTML. Anyway, if you have any thoughts about the scope of R Markdown, feel free to add a comment.
