Get data from ggplot()

This post was originally published here

ggplot includes built in and seamless functionality that summarises your data before plotting it. As shown in the example below, ggplot_build() can be used to access the summarised dataset.

summarised_barplot

R: ISO codes and country names

This post was originally published here

install.packages(‘maps’)

Adding a Cron job using the ed editor

This post was originally published here

These commands (after the first one) work in the ed editor. ed editor is used in the RStudio server shell.

In this example the script will run every 0 hours, 30 minutes, see Ubuntu: How do I set up a CRON job for other options.

Adding space between rows in LaTex tables

This post was originally published here

By default, LaTex tables are very tight:

Adding this to the document preamble will add space between the rows:

And this command can be used to add space between rows manually:

My minimal LaTex preamble

This post was originally published here

My minimal example:

How to “increase” array resolution in R (replicate each element both column-wise and row-wise)

This post was originally published here

One picture says more than a thousand words. You have what is one the left, and you want what is on the right.

resolution_cut

There are a few different ways to do this, but by far the cleanest and quickest way is to just select the rows and columns multiple times, by replicating row and column numbers (instead of actually replicating each element):

Note that by default, in rep(something, n) the n is times so equivalent to rep(something, times=n), but in this case we need to use each instead of times.