Euro 2016 analytics: Who’s playing the toughest game?

Euro 2016 analytics: Who’s playing the toughest game?

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:

_fouls

Continue reading “Euro 2016 analytics: Who’s playing the toughest game?”

Over 50 practical recipes for data analysis with R in one book

Over 50 practical recipes for data analysis with R in one book
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!)
  • fixed some issues with the updateR package
  • and I wrote a book!
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:

RStudio for R Statistical Computing Cookbook

Continue reading “Over 50 practical recipes for data analysis with R in one book”

Rename a Data Frame Within a Function Passing an Argument

Rename a Data Frame Within a Function Passing an Argument

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:

rename_df  =  function(choosen_name){
data_set  =  data.frame(column_A = c(1,4,6,7,8),column_B = c(seq(1:5)))
title  =  choosen_name
assign(title,data_set,pos = ".GlobalEnv")
}

Have you found any other way to get here? I would love to here it!

p.s.: wondering why I chose that image? well, is Adam naming animals.. 🙂

how to list loaded packages in R: ramazon gets cleaver

how to list loaded packages in R: ramazon gets cleaver

It was around midnight here in Italy:
I shared the code on Github, published a post on G+, Linkedin and Twitter and then went to bed.

In the next hours things got growing by themselves, with pleasant results like the following:

The R community found ramazon a really helpful package.

And I actually think it is: Amazon AWS is nowadays one of the most common tools for online web applications and websites hosting.

The possibility to get your Shiny App on it just running a function make it even more desirable for the amusing R people.

Therefore, even if I developed ramazon for personal purposes , I now feel some kind of responsibility to further develop it and take it updated.

Continue reading “how to list loaded packages in R: ramazon gets cleaver”

How to use Github with Rstudio : step-by-step tutorial

How to use Github with Rstudio : step-by-step tutorial

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.

0. download last git version

you can download the last git version from Git website git logo

Continue reading “How to use Github with Rstudio : step-by-step tutorial”

Querying Google With R

Querying Google With R
If you have a blog you may want to discover how your website is performing for given keywords on Google Search Engine. As we all know, this topic is not a trivial one.
Problem is that the analogycal solution would be quite time-consuming, requiring you to search your website for every single keyword, on many many pages.
Feeling this way?
“Pain and fear, pain and fear for me” – Oliver Twist
I was.

Continue reading “Querying Google With R”