create R implementation of puffin tutorial, which was written in python