2024 Nov 06

Reading JSON files as Scheme dataframes

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…


2024 Oct 26

Horse racing game win probability

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 …


2024 Sep 02

RPI and SOS in Scheme, Python, and Elixir

Last spring, I played in a 3x3 basketball leage with 14 teams and only 6 regular-season games. The unbalanced schedule made me wonder if we would end up with wonky playoff seeding. I thought it would be fun to calculate the Rating Percentage Index (RPI) a…


2024 May 30

Proof of Kaprekar's constant in Scheme, Python, and Elixir

I thoroughly enjoyed this delightful post on Kaprekar's constant, which was new to me. Similar to the post author, I also like to use programming to understand mathematical concepts. I thought it would be a fun exercise to translate the example Ruby code …


2024 Apr 22

Dataframe manipulation in Scheme

This is yet another post where I try out my dataframe library for Scheme (R6RS) on examples found in blog posts. This blog post demonstrates data manipulation with dplyr (R). I provide only the Scheme code and some commentary. You will have to click throu…


2024 Mar 27

Comparing dataframe operations in Scheme, Python, and R

I recently came across this blog post that calls pandas (Python) "clunky" compared to the "silky smooth" dplyr (R). No objections from me. dplyr is my favorite R package. I thought it would fun to compare the relative clunkiness of my dataframe library fo…


2023 Jul 08

Exploratory data analysis in Elixir

I have been tinkering with lots of different programming languages (see here and here) over the last few years. Scheme is the only language so far that I have enjoyed enough to write a decent amount of code. Elixir first caught my eye back in April 2020, …


2023 Jul 07

Data transformation in Scheme

I have done some recent work on my dataframe library for Scheme (R6RS) and thought I would run through the examples in the Data Transformation chapter of R for Data Science (R4DS). In this post, I won't reproduce any of the R code and will provide limited…


2022 Aug 21

From Python to NumPy: random walk example in R and Chez Scheme

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…


2021 Jun 05

Visualizing Scheme library procedures with an interactive network graph in R

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…


2021 May 09

Stochastic population model in R, Rcpp, and Fortran

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…


2021 Apr 30

Analyzing gapminder dataset with base R and Scheme

I keep my eye out for blog posts illustrating data analysis tasks in R that I can use to test the functionality of my chez-stats and dataframe libraries for Scheme (R6RS). A post comparing pandas (Python) and dplyr (R) in a basic analysis of the gapminder…


2021 Apr 07

Guess the number game in Fortran

I recently came across this blog post on writing simple test programs in different programming languages as a way to get a feel for a language. At the bottom of the post, there were links to articles on implementations of a number guessing game in 13 diff…


2020 Dec 12

Spam simulation in Scheme

I learned a lot about Scheme (R6RS) by writing a few libraries and I expect that there is more to learn by trying to use those libraries (e.g., EDA in Scheme). A blog post about a stochastic simulation of spam comments in R caught my eye as an interesting…


2020 Dec 12

Stochastic population model in Rust

As I spent a little time learning F# over the last few months, I found that it wasn't holding my attention. My interest in F# was based on the idea that I could write more robust code (via static typing) than in R and that I could more easily turn that co…


2020 Nov 08

Stochastic population model in F#

In three previous posts, I wrote about different programming languages that I have considered learning. I mentioned about 15 different languages in those posts. F# was not on the list. Because my background is in R, I thought I was better off sticking to …

F#

2020 Sep 12

Exploratory data analysis in Scheme

When I started learning Scheme (R6RS), I took the common approach of learning a new language by implementing features from familiar languages (namely R). That approach sent me down the path of writing the dataframe library and porting gnuplot-pipe from Ch…


2020 Sep 05

Modify and aggregate dataframes in Scheme

This post is part of a series on the dataframe library for Scheme (R6RS). In this post, I will contrast the dataframe library with functions from base R and the dplyr package for modifying and aggregating dataframes. Set up First, let's create a dataframe…


2020 May 16

Getting started with Akku package manager for Scheme

Akku is a package manager for Scheme that currently supports numerous R6RS and R7RS Scheme implementations [1]. I was slow to embrace Akku because I encountered some initial friction with installation and setup. Moreover, coming from R, I was more familia…


2020 May 06

ASCII progress bar in Chez Scheme

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 …


2020 Apr 22

Viewing source code in R and Chez Scheme

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…


2020 Apr 09

Filter, partition, and sort dataframes in Scheme

This post is the fourth in a series on the dataframe library for Scheme (R6RS). In this post, I will contrast the dataframe library with functions from the dplyr R package for filtering, partitioning, and sorting dataframes. And discuss implementation dec…


2020 Apr 04

Split, bind, and append dataframes in Scheme

This post is the third in a series on the dataframe library for Scheme (R6RS). In this post, I will contrast the dataframe library with functions from base R and the dplyr package for splitting, binding, and appending dataframes. Set up First, let's creat…


2020 Apr 03

Programming horizons revisited

In my second post on this blog, I wrote about my interest in learning new programming languages and my thoughts on how to choose the next language to learn. It's been over a year since that post and I thought it would be worthwhile to reflect on what I've…


2020 Mar 29

Select, drop, and rename dataframe columns in Scheme

This post is the second in a series on the dataframe library for Scheme (R6RS). In this post, I will contrast the dataframe library with functions from the dplyr R package for selecting, dropping, and renaming columns. Set up First, let's create a very si…


2020 Mar 27

A dataframe record type for Scheme

As an exercise in my Scheme (R6RS) learning journey, I have implemented a dataframe record type and procedures to work with the dataframe record type. Dataframes are column-oriented, tabular data structures useful for data analysis found in several langua…


2020 Mar 01

Reading and writing JSON files in R and Chez Scheme

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…


2020 Feb 19

Avoiding namespace pollution in R and Chez Scheme

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…


2020 Feb 08

Getting started with Chez Scheme and Emacs on Ubuntu

I've been an enthusiastic Mac user for about 12 years, but hardware problems with a recent MacBook Pro and friction surrounding the Catalina upgrade pushed me to evaluate other Unix-like systems. I pulled out an old ASUS laptop that originally had Windows…


2020 Jan 05

Adding string matching to chez-docs

I recently wrote a little library, chez-docs, to make accessing documentation easier while learning Chez Scheme (blog post). The main procedure, doc, in chez-docs only returns results for exact matches with proc [1]. To aid in discovery, I've added a proc…


2020 Jan 01

Access Chez Scheme documentation from the REPL

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 …


2019 Oct 18

Reading and writing CSV files in Chez Scheme

I have added functionality for reading and writing CVS files to my Chez Scheme library, chez-stats. In a previous post, I compared reading CSV files in R and Racket and made the following observation. By and large, R users are not programmers but end us…


2019 Sep 11

Writing a Chez Scheme library

Recently, I switched from learning Racket to Chez Scheme. I wanted to try to repeat some of my previous Racket exercises in Chez Scheme, but quickly ran into a barrier when my first choice required drawing random variates from a normal distribution. I loo…


2019 Aug 03

Getting started with Chez Scheme and Emacs on macOS and Windows

I recently decided to switch my attention from learning Racket to Chez Scheme. One of the reasons that I chose Racket was because of how easy it is to get up and running. Setting up a development environment for Chez requires jumping through a few more ho…


2019 Jul 28

Exploring Scheme implementations

Over the last 6 months, I have been learning Racket in my free time. One of my first posts on this blog laid out my reasons for choosing Racket. The relatively low barrier to entry (e.g., easy installation of Racket and packages, DrRacket IDE, good docs, …


2019 Jul 17

ASCII progress bar in R and Racket

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…


2019 Jul 13

Progress bar widget in R and Racket

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…


2019 Jun 14

Reading and writing JSON files in R and Racket

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…


2019 Jun 09

Reading CSV files in R and Racket

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 …


2019 Jun 07

Free drawing distributions with shinysense

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…


2019 Apr 20

A simple microbenchmarking function in Racket

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)]) …


2019 Apr 15

Vectorized conditional statement in R and Racket

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…


2019 Apr 12

Stochastic population model in R, Rcpp, Racket, and Typed Racket

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…


2019 Apr 05

Generating random numbers in R and Racket

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…


2019 Mar 26

Data serialization in R and Racket

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…


2019 Mar 24

DSM2 interactive map

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…


2019 Mar 20

Storing parameters in named lists and hash tables in R and Racket

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…


2019 Mar 17

Nested for loops in R and Racket

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 …


2019 Mar 10

DataTables from the DT package as a Shiny CRUD app interface

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…


2019 Feb 15

Expanding my programming horizons

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…


2018 Nov 21

Deploying a Shiny app as a desktop application with Electron

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…