R remains my secret weapon πŸ–₯️

For so much I do every day at work, for Save the Pine Bush and for the blog, R remains the tool I use most. R with the tidyverse packages along a few other – namely sf, tigris, tidycensus provide many excellent tools, when tied together with pipes to build amazing data streams.

I think what I like so much about R is it’s an interpretive language at it’s core and the ability to chain commands together with maggitr pipes. You can try something, one line at a time in R, without recompiling, inspect the output, adjust it, and then when you are ready, assign it to a variable. The tidyverse provides several utilities for manipulating data frames, and with tigris and sf, you have the ability to preform all kinds of spatial queries on the data. R makes it easy to do something like pull every record that is within 30 miles of a specific point – or falls in a Census tract where the median income is under $50,000.

So much of what I do at work, for fun or as a volunteer involves joining records together. While such things can be done with SQL and similar languages, there is something so simple and beautiful about the tidyverse, chaining long lists of commands together, keeping each step of the process separate. SQL instead forces you to put everything in one line, and know what you are doing, before you start writing out the command.

As a cherry on the pie, R has the wonderful option of a right-handed assignment. Often when I am writing a command, I am not sure when I want to assign the output to the variable until most of the command is written out. With Python and most other langagues you have to always preform the assignment on the left, which can be hard to do, if you don’t know when you finally want to assign the output variable. Often

Leave a Reply

Your email address will not be published. Required fields are marked *