Alright, now we have all the data we need in one dataframe. To make this code work, I assume you ran the code from Part 1. We need the dataframe big.tab.

All the data presented here is based on the data from 18/10/2012. You can run an analysis with the actual data or I can do it at some point later in the season.

Let's plot some stuff. How about the old german saying about soccer "Geld schießt keine Tore" (Money doesn't score goals)? Let's look into this.


plot(big.tab$Value, big.tab$Goals.for, type = "n", axes = F, xlab = "Value", ylab = "Goals")
text(x = big.tab$Value, y = big.tab$Goals.for, labels = big.tab$Team, cex = 0.7, col = "#65656599")
axis(side = 1)
axis(side = 2)

We get this... (clickable)
Sorry for the overlapping team names. But you get the gist: It looks like the value of a team covaries with the number of goals for that team.

Now we add a regression line. This means, we predict the number of goals for one team by the value of that team. We also add a Pearson correlation coefficient (r) and its associated p value in the subtitle of the plot. We get this...
How do we interpret this? There are several conclusions that could be drawn.

(1) The value of a team in the british Premier League is reliably correlated with the number of goals that team scored in the championship so far (after 7 games). Beware: Correlation does not imply causation.

(2) The "best guess" of predicting the number of goals by the value of a team is visualized by the dashed red line in the second plot. This means that there are teams who "over-perform" and "under-perform" in relation to their value. FC Fulham, for example, shot way "too many" goals given its value. FC Liverpool, on the other hand, should have shot more goals, because they are under the red line.

(3) One could infer from this plot that it is quite difficult for very valuable teams (e.g., ManU, ManCity and the FC Chelsea) to over-perform since the regression line is so steadily rising. So, they have to score many many goals to outperform their level on the regression line.

By the way: This also works quite good for the value of a team and the points they achieved in the championship (win = 3 points, draw = 1 point).
In the next post, I will do some more analyses and plots with this dataset. And I will try to compare different european championships.




0

Add a comment

Hi all, this is just an announcement.

I am moving Rcrastinate to a blogdown-based solution and am therefore leaving blogger.com. If you're interested in the new setup and how you could do the same yourself, please check out the all shiny and new Rcrastinate over at

http://rcrastinate.rbind.io/

In my first post over there, I am giving a short summary on how I started the whole thing. I hope that the new Rcrastinate is also integrated into R-bloggers soon.

Thanks for being here, see you over there.

Alright, seems like this is developing into a blog where I am increasingly investigating my own music listening habits.

Recently, I've come across the analyzelastfm package by Sebastian Wolf. I used it to download my complete listening history from Last.FM for the last ten years. That's a complete dataset from 2009 to 2018 with exactly 65,356 "scrobbles" (which is the word Last.FM uses to describe one instance of a playback of a song).
3

Giddy up, giddy it up

Wanna move into a fool's gold room

With my pulse on the animal jewels

Of the rules that you choose to use to get loose

With the luminous moves

Bored of these limits, let me get, let me get it like

Wow!

When it comes to surreal lyrics and videos, I'm always thinking of Beck. Above, I cited the beginning of the song "Wow" from his latest album "Colors" which has received rather mixed reviews. In this post, I want to show you what I have done with Spotify's API.

Click here for the interactive visualization

If you're interested in the visualisation of networks or graphs, you might've heard of the great package "visNetwork". I think it's a really great package and I love playing around with it. The scenarios of graph-based analyses are many and diverse: whenever you can describe your data in terms of "outgoing" and "receiving" entities, a graph-based analysis and/or visualisation is possible.
12

Here is some updated R code from my previous post. It doesn't throw any warnings when importing tracks with and without heart rate information. Also, it is easier to distinguish types of tracks now (e.g., when you want to plot runs and rides separately). Another thing I changed: You get very basic information on the track when you click on it (currently the name of the track and the total length).

Have fun and leave a comment if you have any questions.
3

So, Strava's heatmap made quite a stir the last few weeks. I decided to give it a try myself. I wanted to create some kind of "personal heatmap" of my runs, using Strava's API. Also, combining the data with Leaflet maps allows us to make use of the beautiful map tiles supported by Leaflet and to zoom and move the maps around - with the runs on it, of course.

So, let's get started. First, you will need an access token for Strava's API.

I've been using the ggplot2 package a lot recently. When creating a legend or tick marks on the axes, ggplot2 uses the levels of a character or factor vector. Most of the time, I am working with coded variables that use some abbreviation of the "true" meaning (e.g. "f" for female and "m" for male or single characters for some single character for a location: "S" for Stuttgart and "M" for Mannheim).

In my plots, I don't want these codes but the full name of the level.

It's been a while since I had the opportunity to post something on music. Let's get back to that.

I got my hands on some song lyrics by a range of artists. (I have an R script to download all lyrics for a given artist from a lyrics website.
4

Lately, I got the chance to play around with Shiny and Leaflet a lot - and it is really fun! So I decided to catch up on an old post of mine and build a Shiny application where you can upload your own GPX files and plot them directly in the browser.

Of course, you will need some GPX file to try it out. You can get an example file here (you gonna need to save it in a .gpx file with a text editor, though). Also, the Shiny application will always plot the first track saved in a GPX file.
9
Blog Archive
BlogRoll
BlogRoll
Loading
Dynamic Views theme. Powered by Blogger. Report Abuse.