R for teachers - WJEC funding from Welsh Government

I've wanted to learn "R" for a long time - the idea of a command line driven (with GUI), open source (ie free) statistical programming language appeals to me. As a long time Minitab user, the output is kind of sucky - difficult to customize charts and the quality of export could be better. R on the other hand is free, infinitely expandable and designed to produce some exceptionally high quality output. Time to learn R.

Getting R is easy:

(1) Download R - https://cran.r-project.org/ - then install it
(2) Download RStudio (provides the development environment - a nice front end) - https://www.rstudio.com/products/rstudio/ - then install it.

Quite easy really.

Then you hit the wall. You see R is not Excel - that means that its not a spreadsheet. Which means the learning curve is steep and yes, it's a programming language.

(3) Buy a book to help (R for Everyone) - well worth the ££
(4) Surf the Interweb for advice.

Using any tool like this needs data - so I moseyed on over to http://gov.wales/about/civilservice/how-we-work/facts-figures/ourfinance/expenditure-over-25k/?lang=en to find data on expenditure over £25K. Being in education, I looked for data on the WJEC.

Some R magic later (plus furious Googling) and I had created:

Nothing special in that chart - could have created it in Excel far quicker. The learning point being that in R, this chart is reporesented by the code it took to create it:

ggplot (WJEC_Year,aes(x=factor(Year),y=Amount))+geom_bar(stat="identity")+labs(title="Welsh Government Funding to WJEC",subtitle="from: http://gov.wales/about/civilservice/how-we-work/facts-figures/ourfinance/expenditure-over-25k/?lang=en",y="Amount(Million)",x="Year";) +scale_y_continuous(labels=function(x)x/1000000)+ theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),panel.background = element_blank(), axis.line = element_line(colour = "black"))

All in one line and that looks very complex (and it is to me too) - but the beauty of this approach is that tweaking the chart is instant and very obvious. For example to change the fill of the bars to RED, you modify the code:

ggplot (WJEC_Year,aes(x=factor(Year),y=Amount))+geom_bar(stat="identity", fill="red")+labs(title="Welsh Government Funding to WJEC",subtitle="from: http://gov.wales/about/civilservice/how-we-work/facts-figures/ourfinance/expenditure-over-25k/?lang=en",y="Amount(Million)",x="Year";) +scale_y_continuous(labels=function(x)x/1000000)+ theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),panel.background = element_blank(), axis.line = element_line(colour = "black"))
I have added in the instruction fill=red - to the command to draw the chart.

This flexibility and control appeals to me.




Christmas holiday hobby - learning R!




comments powered by Disqus