Data Visualizing Global Warming through Shiny

Posted on May 15, 2016
The skills the author demoed here can be learned through taking Data Science with Machine Learning bootcamp with NYC Data Science Academy.
Contributed by Steven Ginsberg.He is currently in the NYC Data Science Academy 12 week full time Data Science Bootcamp program taking place between April 11th to July 1st, 2016. This post is based on his second class project - R Shiny, due on the 2nd week of the program.

My Shiny application (R Code) looks at historical temperatures in an effort to visualize global warming.  NOAA provides worldwide average monthly temperature recordings from this year going all the way back to 1743.  The full data set includes 465,000 records from 7,300 weather stations worldwide.  Filtering this data for the United States only reduced the data set to 181,000 records and 1,900 stations.  In addition, I decided to start the presentation at 1840, just before the number of stations started to

Number of US Weather Stations contributing to the Temperature database

Number of US Weather Stations contributing to the temperature database

increase.

Addtional data is available, such as minimums and maximums as well as precipitation information.  While it would be useful to include these in a variability study, I decided to put this off for another time.

Cleaning up the Data

The data was relatively clean right off the website.  The first issue I encountered was the missing data points were filled in with -9999, making averages and minimums useless.  So these were replaced with NA’s.  The temperatures were stored as degrees Celsius *100, and as integers.  So, divide by 100 to get the two decimal points, convert to Fahrenheit, and they’re good to go.

Avg Temp, all years, all stations

Avg Temp, all years, all stations

NA’s accounted for 83,000 data points or .68% of the total.  I tried replacing the NA’s using k nearest neighbors built into R, but the data set was too large for the memory available.  I did not feel Mean or Random methods were appropriate, so I left the NA’s and ignored them for all average calculations.

A potentially bigger problem than the NA’s was some bad data.  There was a small number of data points with temperatures over 200 degrees.  This throws off averages, maximums and the entire scale of the chart.  These were replaced with NA’s and I was ready to create the application.

The Data Application

The application is simple, with two views of the data, the Chart and a Map.  I used the Shiny dashboard to layout the components, and googleVis for visualizations.

The Chart View

The chart displayed average temperature over time.  The “Year” slider changed the start year, while the end year was fixed to 2016.  The “Month” slider allowed the user to change the averages period viewed, from 1 specific month, 12 months, or seasonally if desired.

For each data set selected, the red line shows the linear trend.  While useful, it is important to note it is not a scientifically or mathematically accurate proof for or against global warming for a few reasons:

  • Taking an average of monthly averages is mathematically inaccurate, and weighs months evenly regardless of the number of days in a month;
  • NA’s are just being ignored and there was no analysis whether there is any bias or relationship to these data points;
  • In addition to the above, there was no analysis of outliers, location bias, etc.
Average Temperature Chart from the application

Average Temperature Chart from the application

The Map View of Data

The map view shows temperatures by location.  The “Year” slider selects the year to display (not a range of years this time) and the "Month" slider selects the months to include in the average.  In all cases, the temps range from blue/cold to orange/hot.  Green dots show NA’s.

View of US Historical Temperatures

View of US Historical Temperatures

Conclusion

Having played with the chart for a while, some interesting patterns emerge.  Generally, we see an upward trend in average temperatures.  However, during the past 20 years this seems to have leveled off.  In addition, during this period it appears Jan – Mar is getting colder, while the rest of the year is level or warmer.  Again, take this all with a grain of salt – this is an example of what can be done from a visual perspective rather than a complete statistically correct study.

About Author

Steven Ginzberg

Steven has spent a number of years performing systems development, financial analysis and management in a variety of companies. Most recently, Steven has been working with start-ups helping them go from conception of ideas, identifying technologies, and finally...
View all posts by Steven Ginzberg >

Leave a Comment

No comments found.

View Posts by Categories


Our Recent Popular Posts


View Posts by Tags

#python #trainwithnycdsa 2019 2020 Revenue 3-points agriculture air quality airbnb airline alcohol Alex Baransky algorithm alumni Alumni Interview Alumni Reviews Alumni Spotlight alumni story Alumnus ames dataset ames housing dataset apartment rent API Application artist aws bank loans beautiful soup Best Bootcamp Best Data Science 2019 Best Data Science Bootcamp Best Data Science Bootcamp 2020 Best Ranked Big Data Book Launch Book-Signing bootcamp Bootcamp Alumni Bootcamp Prep boston safety Bundles cake recipe California Cancer Research capstone car price Career Career Day citibike classic cars classpass clustering Coding Course Demo Course Report covid 19 credit credit card crime frequency crops D3.js data data analysis Data Analyst data analytics data for tripadvisor reviews data science Data Science Academy Data Science Bootcamp Data science jobs Data Science Reviews Data Scientist Data Scientist Jobs data visualization database Deep Learning Demo Day Discount disney dplyr drug data e-commerce economy employee employee burnout employer networking environment feature engineering Finance Financial Data Science fitness studio Flask flight delay gbm Get Hired ggplot2 googleVis H20 Hadoop hallmark holiday movie happiness healthcare frauds higgs boson Hiring hiring partner events Hiring Partners hotels housing housing data housing predictions housing price hy-vee Income Industry Experts Injuries Instructor Blog Instructor Interview insurance italki Job Job Placement Jobs Jon Krohn JP Morgan Chase Kaggle Kickstarter las vegas airport lasso regression Lead Data Scienctist Lead Data Scientist leaflet league linear regression Logistic Regression machine learning Maps market matplotlib Medical Research Meet the team meetup methal health miami beach movie music Napoli NBA netflix Networking neural network Neural networks New Courses NHL nlp NYC NYC Data Science nyc data science academy NYC Open Data nyc property NYCDSA NYCDSA Alumni Online Online Bootcamp Online Training Open Data painter pandas Part-time performance phoenix pollutants Portfolio Development precision measurement prediction Prework Programming public safety PwC python Python Data Analysis python machine learning python scrapy python web scraping python webscraping Python Workshop R R Data Analysis R language R Programming R Shiny r studio R Visualization R Workshop R-bloggers random forest Ranking recommendation recommendation system regression Remote remote data science bootcamp Scrapy scrapy visualization seaborn seafood type Selenium sentiment analysis sentiment classification Shiny Shiny Dashboard Spark Special Special Summer Sports statistics streaming Student Interview Student Showcase SVM Switchup Tableau teachers team team performance TensorFlow Testimonial tf-idf Top Data Science Bootcamp Top manufacturing companies Transfers tweets twitter videos visualization wallstreet wallstreetbets web scraping Weekend Course What to expect whiskey whiskeyadvocate wildfire word cloud word2vec XGBoost yelp youtube trending ZORI