Skip to content

Language

R Markdown: hide code blocks

In writing an R Markdown document to describe a within-host malaria model that I'm working on, I have focused on the HTML version of the document and made use of code folding to hide several code blocks by default.

The PDF version of the document includes the complete listing of each code block, but I instead wanted to remove the folded code blocks from the PDF version. And while it took me a long time to find a solution, the solution itself is quite simple.

R functions as knitr chunks

In writing an R Markdown document to describe a within-host malaria model that I'm working on, I discovered that knitr::read_chunk() only accepts fixed line numbers and # ---- some-label marker comments. So I've implemented read_function_chunks(), below, which extracts each top-level function as a separate chunk, and supports including roxygen documentation comments.

Compartmental models in Rust

I've been learning a bit of Rust in the past few weeks, mostly by writing some basic SIR-type models (both as ODE systems, and as continuous-time and discrete-time Markov chains). It takes most (maybe all) of the things that I like about OCaml and adds more great features and safety guarantees, thanks to its ownership model and lifetimes. It's also very fast (no garbage collector, zero-cost abstractions) and has fantastic tooling, although compilation times can be very long, and package ("crate") availability can be very hit-or-miss. I've enjoyed it enough that I'm looking forward to writing more Rust code in the future. Although I've no plans to rewrite pypfilt or epifx in Rust any time soon!

Biological modelling and domain-specific languages

In "The Layer-Oriented Approach to Declarative Languages for Biological Modeling", Raikov and De Schutter propose a "layer-oriented" declarative language to map high-level biological concepts to computational representations. The layer-oriented approach was chosen because "additional functionality can be transparently added to the language by adding more layers".

This is an area that has interested me ever since I began my PhD. Domain-specific languages are a very neat way to express computational problems in a manner that (hopefully) captures the essentials of the problem domain with a minimum of noise. And declarative languages (e.g., logic languages such as Prolog and Mercury, and functional languages such as Haskell and OCaml) are more readily able to express the logic of a problem without (overly) digressing into the algorithmic details of solving the problem.