In a previous post, I wrote about reading and writing JSON files in R and Chez Scheme. After updating that post, I was curious about how much code it would take to convert a Scheme object read from a JSON file into a dataframe. It is arguably a rare circu…
When gathering with family, we like to play yard, card, and board games. On a recent visit, one of the favorite games was the Across the Board Kentucky Derby Horse Racing Game. The game produced a lot of cheers and jeers and provided a fun diversion with …
As a learning exercise, I decided to translate examples from the book, From Python to NumPy, into R and Chez Scheme. This post describes the random walk example from Chapter 2. All of the code is in this repository so I will only highlight a few pieces of…
As a learning exercise, I wrote a dataframe library for Scheme (R6RS). Because I was learning Scheme while I wrote dataframe, I did not prioritize performance. However, as I've tried to use the dataframe library (exploratory data analysis, spam simulation…
The stochastic logistic population model described in this blog post has become my default exercise when I'm exploring a new programming language (Racket, F#, Rust). I ended that Rust post by noting that I was interested in Rust as a modern alternative fo…
As an impatient person, I typically use progress bars for any code that takes more than a few minutes to run. In a previous post, I wrote about creating ASCII progress bars in R and Racket. The Racket version depended on the raart module, which "provides …
One of the advantages of open source software is being able to view, review, and learn from source code. Both R and Chez Scheme provide tools for accessing source code. R cfs.misc is a small package with a few utility functions that are useful to our work…
I have previously written about how to read and write JSON files in R and Racket. In re-reading that old post, I'm struck by how it shows me tinkering without understanding. Now that I have pivoted from learning Racket to learning Chez Scheme, I'm revisit…
I was reading a blog post that mentioned that Julia has "[w]eak conventions about namespace pollution" and it got me thinking about how I manage namespace pollution in R and Chez Scheme. The short answer is that I don't. I developed bad habits in R center…
In the process of learning Chez Scheme, I've missed R's ability to quickly pull up documentation from the console via help or ?. I've toyed with the idea of trying to format the contents of the Chez Scheme User's Guide for display in the REPL (similar to …
In a previous post, I used GUI toolkits to make progress bars in R and Racket. However, I usually prefer the ASCII progress bars of the progress package in R. The progress package includes several options for formatting the progress bar. I particularly li…
As an impatient person and an insecure programmer, I typically use progress bars for any code that takes more than a few minutes to run. In R, a progress bar widget is available through the tcltk package. library(tcltk) pb <- tkProgressBar(title = &qu…
In learning about reading CSV files in Racket, I have started to reconsider whether storing small(ish) datasets in CSV files is the best default behavior [1]. My default was set by primarily working in R, where reading and writing CSV files plays a centra…
In a previous post, I wrote about reading and writing data to file while retaining the structure and attributes of the data (i.e., data serialization). However, I more commonly pass data around as text files (usually, CSV files). For this post, I created …
One of the areas of expertise at Cramer Fish Sciences is watershed and habitat restoration. In the context of that work, we are often faced with estimating how much rearing habitat is needed to support a specified number of juvenile salmonids (or how many…
In a previous post, I wrote a function to perform repeated timings of untyped and typed versions of the same Racket functions. #lang racket (require math) (define (time-apply-cpu-old proc lst reps) (define out (for/list ([i (in-range reps)]) …
Racket's if is not vectorized like ifelse in R. Instead, this Racket code (if (test-expr) true-expr false-expr) is the same as this R code. if (test_expr){ true_expr } else { false_expr } In contrast, R's ifelse function is vectorized meanin…
On my journey to learn Racket, I look for small pieces of R code to try to implement in Racket. A blog post about speeding up population simulations in R with the Rcpp package seemed like a good candidate for implementing in Racket. I was particularly int…
R makes it easy to generate random numbers from a wide variety of distributions with a consistent interface. For example, runif, rnorm, and rpois generate random numbers from uniform, normal, and Poisson distributions, respectively. > x = runif(n = 100…
When programming in R, I generally pass data around by reading and writing text files (typically, CSV files). The ubiquity of CSV files means that many different types of software will open them easily (e.g., Notepad, Excel, TextEdit, etc.). However, if t…
The Delta Simulation Model II (DSM2) is a hydrodynamic model used for Sacramento-San Joaquin Delta planning and management. When working with DSM2 output, I frequently need to look up the location of channels, nodes, and stations in the model. A map of al…
When building a simulation model in R, I might want to group related input parameters into a data structure. For example, in a life cycle model with resident and anadromous fish, you might use different fecundity parameters for each life history type. One…
I have recently started learning Racket. For a first task, I tried to build a simple age-structured population model. I hit a stumbling block and reached out to the helpful folks on the Racket mailing list. In this post, I recap the mailing list exchange …
Shiny Scorekeeper is a basketball scorekeeper app built with the Shiny web framework for R. I needed a new app for scoring video of my son's basketball games and I decided it would be a good learning experience to try to build my own. In this post, I desc…
For many years, I've had intentions of learning another programming language. I would guess that I've done 70-80% of my programming work in R and 20-30% in NetLogo. Those two languages have served me well and I haven't yet been in a position where I was r…
In developing the DSM2 HYDRO Viz Tool, we were faced with deciding how to deploy a Shiny app that required interaction with large local files. I first heard about the possibility of using Electron to deploy Shiny apps as standalone desktop applications in…