{"cells":[{"metadata":{"_uuid":"742b8c304c9e6b3eed1e56878b993c70ed420dd7"},"cell_type":"markdown","source":"#Graphing a Punt Play in R\n\nI have never worked with geospatial data, so I figured a good first step would be to learn how to make a simple plot of a punt play. This work was inspired by a Kernel by [Kevin Mader](http://https://www.kaggle.com/kmader/previewing-the-games). "},{"metadata":{"_uuid":"f08f2d7c2f27eb424ce23ee9d9afe03d122c8ab4","_execution_state":"idle","trusted":true},"cell_type":"code","source":"#load in the data and filter out a single punt play\nlibrary(tidyverse)\ndata <- read.csv('../input/NGS-2016-post.csv') %>%\n    filter(PlayID == 2983)","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"984c7c6798d8329ef6c8e54837f06b4b33930485"},"cell_type":"markdown","source":"In order to graph the play, I needed to create a field that contains two seperate endzones. The field is colored palegreen and the endzones are colored red and blue respectively."},{"metadata":{"trusted":true,"_uuid":"ef561196681abbf02bdacb3bddfc02b875456afa"},"cell_type":"code","source":"#https://www.kaggle.com/kmader/previewing-the-games\nggplot(data, aes(x,y)) +\n    geom_rect(aes(xmin=-10, xmax=110, ymin=0, ymax=53.3), fill = 'palegreen', alpha = 0.1) +\n    geom_rect(aes(xmin=-10, xmax=0, ymin=0, ymax=53.3), fill = 'red') +\n    geom_rect(aes(xmin=100, xmax=110, ymin=0, ymax=53.3), fill = 'blue') +\n    geom_point(aes(colour = factor(GSISID)))","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"21249e102adbace1f5a3435216d7bace4a919fa1"},"cell_type":"markdown","source":"This project is still a work in progress. The next step that I want to accomplish is to animate the graph above. If you know of any resources to do this, feel free to leave them in the comments below. Also feel free to leave any improvements or ideas that you would like to see. Thanks for reading!"}],"metadata":{"kernelspec":{"display_name":"R","language":"R","name":"ir"},"language_info":{"mimetype":"text/x-r-source","name":"R","pygments_lexer":"r","version":"3.4.2","file_extension":".r","codemirror_mode":"r"}},"nbformat":4,"nbformat_minor":1}