I am really enjoying Uefa Euro 2016 Footbal Competition, even because our national team has done pretty well so far. That’s why after browsing for a while statistics section of official EURO 2016 website I decided to do some analysis on the data they share ( as at the 21th of June).
Just to be clear from the beginning: we are not talking of anything too rigourus, but just about some interesting questions with related answers gathered mainly through data visualisation.
We can divide following analyses into two main parts: a first part were we analyse distribution of fouls and their incidence on matches outcome and a second part where ball possession in analysed, once again looking at relationship between this stat and matches outcome. Let’s start with fouls then.
which team committed the greatest number of fouls?
Here we are with the first question. And here it is the answer:
Ah, writing a blog post! This is a pleasure I was forgetting, and you can guess it looking at last post date of publication: it was around january... you may be wondering: what have you done along this long time? Well, quite a lot indeed:
changed my job ( I am now working @ Intesa Sanpaolo Banking Group on Basel III statistical models)
became dad for the third time (and if you are guessing, it’s a boy!)
Hope this pretty long list will help you forgive me for my long silence. I am actually pretty proud of all of them, but let’s talk about the book now. I think it is an useful contribution to the R community. But first of all, the title:
This is not actually a real post but rather a code snippet surrounded by text.
Nevertheless I think it is a quite useful one: have you ever found yourself writing a function where a data frame is created, wanting to name that data frame based on a custom argument passed to the function?
For instance, the output of your function is a really nice data frame name in a really trivial way, like “result”.
But your dream is to let the user (or some piece of code behind the function) specify the data frame name, passing it as an argument of your function.
To achieve that you need to look at assign function, which let’s you access the hash table of a given environment (pos argument) and change the value of a given variable.
Find below a working function which applies this idea:
Pushing to my Github repository directly from the Rstudio project, avoiding that annoying “copy & paste” job. Since it is one of Best Practices for Scientific Computing, I have been struggling for a while with this problem. Now that I managed to solve the problem, I think you may find useful the detailed tutorial that follows. I am not going to explain you the reason why you should use Github with your Rstudio project, but if you are asking this to yourself, you may find useful a Stack Overflow discussion on the topic.