METEO 810
Weather and Climate Data Sets

Lesson 3. Working with R

Motivate...

photo of old tools
Tools make difficult tasks easier.

What role do tools play in your daily life? Perhaps you might respond, "I'm not really a handy person... I don't use tools very often." Well, I'm not just talking about the hammer or screwdriver kind of tools. If you search for a general definition of a tool, you might run across something like the following: "A broader definition of a tool is an entity used to interface between two or more domains that facilitates more effective action of one domain upon the other." (definition from Wikipedia). What does this mean, exactly? One simple interpretation is this, "A tool makes a particular task easier". Think about it. Everything that you use to make something easier is a tool. When you clean your teeth, you use a tool. When you communicate with someone, you most often use some sort of tool. When you want to collect and analyze information, you use tools. Indeed, you are surrounded by a multitude of tools that you use without even thinking about it.

If we are to make sense out of the mountain of weather data available to us, we are going to need some tools specifically designed for this task. There are certainly some excellent data analysis tools available. Perhaps you even make use of them now. As I mentioned in the orientation material, we are going to use the open-source statistical package "R" (You should already be somewhat familiar with how R works). Before we dive into using "R", first let me give you my philosophy on using statistical tools such as this...

  • This is not a programming course. The purpose of this course is to get you analyzing data, not teach you to become an "R" programming expert.  Indeed, you may explore all you wish, but you need do so only as you feel comfortable. "R" is a tool and we will use it as such. Think of "R" as just another electrical appliance. I'm sure that you know of someone who can't rest until they take that appliance apart and understand how it works. The rest of us just want to know how to use it. You are free to treat "R" in the same manner -- just use it, or take it apart and learn everything there is to know about it.
  • That said, you must become comfortable using R. As I have said, R is especially designed for data analysis.The software contains some powerful tools that you will learn to use, not only in this course, but in the courses that follow. Some folks ask me why they can't just use Excel. Indeed, Excel can handle some of the tasks that we will be performing early on, but at some point relatively soon in this course, our needs will far exceed Excel's capabilities.
  • In learning R, know that it is OK (even encouraged) to copy the commands that I provide. Since "R" is open source, users from all over the world have designed and shared some very useful extensions for analyzing almost anything you can imagine. I will show you how to find and make use of others' efforts to help solve your own problems.
  • If you are an "R" super-user, feel free to use your own workflow. There are many different ways to do the same task in "R". Perhaps you know of a better way than I present in the lesson material. You are welcome to continue using that method (you might even consider sharing it with the class).

I hope this allays any remaining uneasiness you might have about learning programming. Remember that you can always turn to me or your fellow classmates if you lose your way.

"R" you ready? Read on!

Lesson Objectives

After completing this lesson, you should be able to:

  • execute scripts, load data and perform simple manipulations in R;
  • use R to create simple and sophisticated 2D plots;
  • use R to plot histograms and box plots;
  • create image and contour plots in R;
  • load and use custom library plotting tools for specialized data sets;
  • describe several methods for incorporating (or excluding) missing values from data;
  • describe methods for transforming data which might be easily interpreted due to its values; and
  • discuss approaches for debugging R script which may not be working correctly.
Download all of this lesson’s code and data.
I've packaged up all of the data files and scripts that you will need for this lesson. Clicking on the link will prompt you to save a .zip file to your computer. Extract the files to your Lesson 3 working directory.