r

Finding an SPSS {haven}

My education as a social scientist—undergratuate studies in sociology and anthropology—was largely focused on theory and the application of theory to social problems. For the most part, I taught myself how to apply those methods through R. I was fortunate enough to have avoided ever using SPSS. Perhaps that is good. Perhaps it is not. The use of R in the social sciences is increasing and I will go as far as to say that that is great news.

{genius}

An R package for acquiring song lyrics in a tidy format.

Intro to Tidy Modeling

This is a resource intended to provide a top-level introduction into the main aspects of tidymodels. The introduction into tidyverse concepts largely adapted from Thomas Mock’s Intro to the Tidyverse. Content was also adapted from the Max Kuhn’s Applied Machine Learning content as well as Edgar Ruiz’s Gentle Introduction to Tidymodels. View source code here. Intro to Tidy modeling Prediction API Prediction App This repository contains the resources used for a brief (~1hr) introduction to tidymodels.

Water Quality Analysis

This small tutorial was developed for a talk / workshop that Phil Bowsher gave at the EPA. This serves as a quick example of using the tidyverse for spatial analysis, modeling, and interactive mapping. The source code and data can be found here. EPA Water Quality Analysis Data Cleaning This section outlines the process needed for cleaning data taken from EPA.gov. There are two datasets:

∑ { my parts }

library(tidyverse) terrorists <- googlesheets::gs_url("https://docs.google.com/spreadsheets/d/1LYQakIwGosibDHJKJqZgjM39qpSlp_gFG29zJ6paDAI/edit#gid=956062857") %>% googlesheets::gs_read() terrorist_by_race ## # A tibble: 7 x 6 ## race n fatalities injured total_victims `%` ## <chr> <int> <dbl> <dbl> <dbl> <dbl> ## 1 white 63 554 1067 1621 69.3 ## 2 other 5 90 115 205 8.77 ## 3 black 19 108 89 197 8.43 ## 4 asian 8 77 33 110 4.70 ## 5 unclear 6 40 61 101 4.32 ## 6 latino 10 44 33 77 3.

Google Trends for Campaigns

Over the past few years we have seen Google Trends becoming quite ubiquitous in politics. Pundits have used Google seach trends as talking points. It is not uncommon to hear news about a candidates search trends the days following a town hall or significant rally. It seems that Google trends are becoming the go to proxy for a candidate’s salience. As a campaign, you are interested in the popularity of a candidate relative to another one.

Web-scraping for Campaigns

As the primaries approach, I am experiencing a mix of angst, FOMO, and excitement. One of my largest concerns is that progressive campaigns are stuck in a sort of antiquated but nonetheless entrenched workflow. Google Sheets reign in metric reporting. Here I want to present one use case (of a few more to come) where R can be leveraged by your data team. In this post I show you how to scrape the most recent polling data from FiveThirtyEight.

genius tutorial

Introducing genius You want to start analysing song lyrics, where do you go? There have been music information retrieval papers written on the topic of programmatically extracting lyrics from the web. Dozens of people have gone through the laborious task of scraping song lyrics from websites. Even a recent winner of the Shiny competition scraped lyrics from Genius.com. I too have been there. Scraping websites is not always the best use of your time.

genius Plumber API

get started here Since I created genius, I’ve wanted to make a version for python. But frankly, that’s a daunting task for me seeing as my python skills are intermediate at best. But recently I’ve been made aware of the package plumber. To put it plainly, plumber takes your R code and makes it accessible via an API. I thought this would be difficult. I was so wrong. Using plumber Plumber works by using roxygen like comments (#*).

xgboost feature importance

This post will go over extracting feature (variable) importance and creating a function for creating a ggplot object for it. I will draw on the simplicity of Chris Albon’s post. For steps to do the following in Python, I recommend his post. If you’ve ever created a decision tree, you’ve probably looked at measures of feature importance. In the above flashcard, impurity refers to how many times a feature was use and lead to a misclassification.