Browsed by
Month: July 2016

Enriching Datasets with R

Enriching Datasets with R

If you have a simple data set and have some additional statistics you’d like to add to that dataset you can easily do that with R. Going to add fip, woba, wrc, and wraa to a couple of baseball datasets as an example of this. To calculate FIP I first needed the following R functions: [code language=”r”] #Calculate FIP Constant fip_constant_calc <- function(pitching_data){ #FIP Constant = lgERA – (((13*lgHR)+(3*(lgBB+lgHBP))-(2*lgK))/lgIP) era = sum(pitching_data["ER"])/sum(pitching_data["IP"]) * 9 lgHR = sum(pitching_data["HR"]) lgBB = sum(pitching_data["BB"])…

Read More Read More

Why Reynaldo?

Why Reynaldo?

The Nationals sent Lucas Giolito back down to the minors and have called up Reynaldo Lopez for his Major League debut tomorrow. So I decided to take a look at possible reasons for that decision. Giolito did ok in his first rain shortened start giving up only 1 hit in 4 innings but the 2 BB’s were a little concerning. Especially since this season he’s had a pattern of walking people to a tune of 4.3 BB/9 in the Eastern…

Read More Read More

An Example CSV to Mongo Dataflow

An Example CSV to Mongo Dataflow

Do you have a bunch of CSV files laying around that you’d like to be able to run queries against? This post is going to discuss a way to do that with Apache Camel and a processor I wrote. Prerequisites: Ability to run a mvn camel:run A MongoDB installation available Technologies used: Apache Camel Maven MongoDB Wrote a Custom camel processor to take in a CSV file and turn it into JSON. Jackson was my tool of choice for converting…

Read More Read More

Learning wOBA

Learning wOBA

As I continue to learn R and go down the road of becoming a data scientist. I need to learn how to use and compute advanced statistics. The first advanced analytic I’m going to learn how to compute is weighted on-base average(wOBA). Weighted on-base average combines all the parts of a players offensive game and gives them all appropriate weights for their impact on the game. For example, a HR is given more weight than a BB or a Single…

Read More Read More

JSON to CSV with Jackson

JSON to CSV with Jackson

Needed to convert some JSON output to CSV this week on one of my REST endpoints. Previously on this endpoint I was using Gson to do the conversion. Gson does not natively support JSON to CSV conversion. So though I love how easy it is for me to type: [code language=”java”] Gson gson = new Gson(); gson.toJson("Hello World"); [/code] and easily retrtieve my Json. I switched over to using Jackson because it does support CSV conversion of my Pojos as…

Read More Read More

Exploratory Data Analysis using Minor League Batting Statistics

Exploratory Data Analysis using Minor League Batting Statistics

Similar to graphically looking at Nationals minor league pitching stats I wanted to do the same with their minor league hitting stats per team. I decided to look at how the Nationals minor league team OPS is doing relative to their league and level. OPSĀ is a players OBP added to their SLG measure how good a player is doing offensively when those two metrics are taken into account. Since pitchers also bat I needed to do some data cleaning or…

Read More Read More