## Set operations – Measuring set overlaps / Venn diagrams for vectors

To count how many elements of two sets overlap, one could write a custom function: xtab_set <- function(A, B){ both &...

To count how many elements of two sets overlap, one could write a custom function: xtab_set <- function(A, B){ both &...

Recycling can be used in a clever way to simplify code. Subsetting If we want to keep every third element of a vector we...

Exporting using base R Data can be written to a CSV file using write.csv(): write.csv(mtcars, "mtcars.csv") Co...

Let’s take an example of adding a value to a range (as it could be done in a loop for example): 3+1:5 Gives: [1] 4...

Let A and B be two matrices of same dimension. The operators +,-,/,*,^ when used with matrices of same dimension perform...

You can create a new notebook in RStudio with the menu command File -> New File -> R Notebook If you don’t s...

A data.frame is a special kind of list: it is rectangular. Each element (column) of the list has same length, and where ...

The following example utilizes the tm text mining package to scrape and mine text data from the web to build word clouds...

sqldf() from the package sqldf allows the use of SQLite queries to select and manipulate data in R. SQL queries are ente...

Within C++, one can set different compilation flags using: // [[Rcpp::plugins(name)]] List of the built-in plugins: // b...

Viridis (named after the chromis viridis fish) is a recently developed color scheme for the Python library matplotlib (t...

The basic math operations are performed mainly on numbers or on vectors (lists of numbers). 1. Using single numbers We c...

Recoding missing values Regularly, missing data isn’t coded as NA in datasets. In SPSS for example, missing values...

Long vectors with long runs of the same value can be significantly compressed by storing them in their run-length encodi...

The foreach package brings the power of parallel processing to R. But before you want to use multi core CPUs you have to...