<p><div><div><div><div data-width="100" data-show-faces="false" data-send="true" data-layout="button_count" data-height="21" data-href="https://www.r-bloggers.com/pisa-2015-how-to-readprocessplot-the-data-with-r/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://smarterpoland.pl/index.php/2016/12/pisa-2015-how-to-readprocessplot-the-data-with-r/"> SmarterPoland.pl » English</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>Yesterday OECD has published results and data from PISA 2015 study (<a target="_blank" rel="nofollow" href="https://en.wikipedia.org/wiki/Programme_for_International_Student_Assessment">Programme for International Student Assessment</a>). It’s a very cool study – over 500 000 pupils (15-years old) are examined every 3 years. Raw data is publicly available and one can easily access detailed information about pupil’s academic performance and detailed data from surveys for studetns, parents and school officials (~2 000 variables). Lots of stories to be found.</p>
<p>You can download the dataset in the SPSS format from <a target="_blank" rel="nofollow" href="http://www.oecd.org/pisa/data/2015database/">this webpage</a>. Then use the <a target="_blank" rel="nofollow" href="https://cran.r-project.org/web/packages/foreign/index.html">foreign</a> package to read sav files and <a target="_blank" rel="nofollow" href="https://github.com/eldafani/intsvy">intsvy</a> package to calculate aggregates/averages/tables/regression models (for 2015 data you shall use the GitHub version of the package). </p>
<p>Below you will find a short example, how to read the data, calculate weighted averages for genders/countries and plot these results with ggplot2. <a target="_blank" rel="nofollow" href="http://users.ox.ac.uk/~educ0279/">Here you will find</a> other use cases for the intsvy package.</p>
<p><a target="_blank" rel="nofollow" href="https://i0.wp.com/smarterpoland.pl/wp-content/uploads/2016/12/pisa2015.png"><img alt="pisa2015" class="wp-image-7596" src="https://i0.wp.com/smarterpoland.pl/wp-content/uploads/2016/12/pisa2015-1014x1024.png?resize=456%2C461" data-recalc-dims="1"></a></p>

<pre>library(&quot;foreign&quot;)
library(&quot;intsvy&quot;)
library(&quot;dplyr&quot;)
library(&quot;ggplot2&quot;)
library(&quot;tidyr&quot;)

stud2015 &lt;- read.spss(&quot;CY6_MS_CMB_STU_QQQ.sav&quot;, use.value.labels = TRUE, to.data.frame = TRUE)
genderMath &lt;- pisa2015.mean.pv(pvlabel = &quot;MATH&quot;, by = c(&quot;CNT&quot;, &quot;ST004D01T&quot;), data = stud2015)

genderMath &lt;- genderMath[,c(1,2,4,5)]
genderMath %>%
  select(CNT, ST004D01T, Mean) %>%
  spread(ST004D01T, Mean) -> genderMathWide

genderMathSelected &lt;-
  genderMathWide %>%
  filter(CNT %in% c(&quot;Austria&quot;, &quot;Japan&quot;, &quot;Switzerland&quot;,  &quot;Poland&quot;, &quot;Singapore&quot;, &quot;Finland&quot;, &quot;Singapore&quot;, &quot;Korea&quot;, &quot;United States&quot;))

pl &lt;- ggplot(genderMathWide, aes(Female, Male)) +
  geom_point() +
  geom_point(data=genderMathSelected, color=&quot;red&quot;) +
  geom_text(data=genderMathSelected, aes(label=CNT), color=&quot;grey20&quot;) +
  geom_abline(slope=1, intercept = 0) + 
  geom_abline(slope=1, intercept = 20, linetype = 2, color=&quot;grey&quot;) + 
  geom_abline(slope=1, intercept = -20, linetype = 2, color=&quot;grey&quot;) +
  geom_text(x=425, y=460, label=&quot;Boys +20 points&quot;, angle=45, color=&quot;grey&quot;, size=8) + 
  geom_text(x=460, y=425, label=&quot;Girls +20 points&quot;, angle=45, color=&quot;grey&quot;, size=8) + 
  coord_fixed(xlim = c(400,565), ylim = c(400,565)) +
  theme_bw() + ggtitle(&quot;PISA 2015 in Math - Gender Gap&quot;) +
  xlab(&quot;PISA 2015 Math score for girls&quot;) +
  ylab(&quot;PISA 2015 Math score for boys&quot;)</pre>
<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="http://smarterpoland.pl/index.php/2016/12/pisa-2015-how-to-readprocessplot-the-data-with-r/"> SmarterPoland.pl » English</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a title="The R Project for Statistical Computing" rel="nofollow" href="https://www.r-project.org/">R</a> news and <a title="R tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/tutorial">tutorials</a> on topics such as: <a title="Data science" rel="nofollow" href="https://www.r-bloggers.com/search/data%20science">Data science</a>, <a title="Big Data" rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data">Big Data, <a title="R jobs" rel="nofollow" href="https://www.r-users.com/">R jobs</a>, visualization (<a title="ggplot and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2">ggplot2</a>, <a title="Boxplots using lattice and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/boxplot">Boxplots</a>, <a title="Maps and gis" rel="nofollow" href="https://www.r-bloggers.com/search/map">maps</a>, <a title="Animation in R" rel="nofollow" href="https://www.r-bloggers.com/search/animation">animation</a>), programming (<a title="RStudio IDE for R" rel="nofollow" href="https://www.r-bloggers.com/search/RStudio">RStudio</a>, <a title="Sweave and literate programming" rel="nofollow" href="https://www.r-bloggers.com/search/sweave">Sweave</a>, <a title="LaTeX in R" rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX">LaTeX</a>, <a title="SQL and databases" rel="nofollow" href="https://www.r-bloggers.com/search/SQL">SQL</a>, <a title="Eclipse IDE for R" rel="nofollow" href="https://www.r-bloggers.com/search/eclipse">Eclipse</a>, <a title="git and github, Version Control System" rel="nofollow" href="https://www.r-bloggers.com/search/git">git</a>, <a title="Large data in R using Hadoop" rel="nofollow" href="https://www.r-bloggers.com/search/hadoop">hadoop</a>, <a title="Web Scraping of google, facebook, yahoo, twitter and more using R" rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping">Web Scraping</a>) statistics (<a title="Regressions and ANOVA analysis tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/regression">regression</a>, <a title="principal component analysis tutorial" rel="nofollow" href="https://www.r-bloggers.com/search/PCA">PCA</a>, <a title="Time series" rel="nofollow" href="https://www.r-bloggers.com/search/time+series">time series</a>, <a title="finance trading" rel="nofollow" href="https://www.r-bloggers.com/search/trading">trading</a>) and more...
<img height="1" alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/4qB6aBsVAgk"></a></div>