A new R package diagonals is now available on CRAN. The package implements several tools for dealing with fat diagonals on matrices, such as this one:

Fat diagonal matrices occur when we combine two dimensions of a data set along one edge of a matrix. For example, trade-flow data in the decompr and gvc package have each country-industry combination occur on each edge of the matrix.

The workhorse function of this package is the fatdiag function, which tries behave similarly to the diag function from the base package, but then with diagonals being fat.

We can also use the function to assign values to the diagonal.

As can be seen from the above example, the blocks and matrices do not have to be square.

The diagonal of a matrix can also be extracted.

We can also specify the size of the block in stead of the number of steps.

This also gives us flexibility in terms of having non-square blocks (and consequently matrices).

The attention R package, describing how to implement from scratch the attention mechanism - which forms the basis of transformers - in the R language is now ...

EDIT 2022-06-24: this code is now available (with helper functions) in the R package attention, which is on CRAN. You can install it simply using:
install.pa...

With over a year working from home and an end not immediately in sight, I felt it was time to think a bit structurally about how to work remotely as effectiv...

For a job interview at WHO I was asked by build a numeric version of Noughts and Crosses (Tic-Tac-Toe to some), this is called Ron Grahamâ€™s Game (repo).