Learn R Programming

weatherData (version 0.5.0)

getWeatherForDate: Getting data for a range of dates

Description

This function will return a (fairly large) data frame. If you are going to be using this data for future analysis, you can store the results in a CSV file by setting opt_write_to_file to be TRUE

Usage

getWeatherForDate(station_id, start_date, end_date = NULL,
  station_type = "airportCode", opt_detailed = FALSE,
  opt_write_to_file = FALSE, opt_temperature_columns = TRUE,
  opt_all_columns = FALSE, opt_custom_columns = FALSE,
  custom_columns = NULL, opt_verbose = FALSE, daily_min = FALSE,
  daily_max = FALSE)

Arguments

station_id

is a valid 3- or 4-letter Airport code or a valid Weather Station ID (example: "BUF", "ORD", "VABB" for Mumbai). Valid Weather Station "id" values: "KFLMIAMI75" or "IMOSCOWO2" You can look these up at wunderground.com

start_date

string representing a date in the past ("YYYY-MM-DD", all numeric)

end_date

If an interval is to be specified, end_date is a string representing a date in the past ("YYYY-MM-DD", all numeric) and greater than the start_date (Optional)

station_type

= "airportCode" (3- or 4-letter airport code) or "ID" (Wx call Sign)

opt_detailed

Boolen flag to indicate if detailed records for the station are desired. (default FALSE). By default only one records per date is returned.

opt_write_to_file

If TRUE, the resulting dataframe will be stored in a CSV file. Default is FALSE

opt_temperature_columns

Boolen flag to indicate only Temperature data is to be returned (default TRUE)

opt_all_columns

Boolen flag to indicate whether all available data is to be returned (default FALSE)

opt_custom_columns

Boolen flag to indicate if only a user-specified set of columns are to be returned. (default FALSE) If TRUE, then the desired columns must be specified via custom_columns

custom_columns

Vector of integers specified by the user to indicate which columns to fetch. The Date column is always returned as the first column. The column numbers specfied in custom_columns are appended as columns of the data frame being returned (default NULL). The exact column numbers can be found by visiting the weatherUnderground URL, and counting from 1. Note that if opt_custom_columns is TRUE, then custom_columns must be specified.

opt_verbose

Boolean flag to indicate if verbose output is desired

daily_min

A boolean indicating if only the Minimum Temperatures are desired

daily_max

A boolean indicating if only the Maximum Temperatures are desired

Value

A data frame with each row containing:

  • Date and Time stamp (for each date specified)

  • Temperature and/or other weather columns sought

Details

For each day in the date range, this function fetches Weather Data. Internally, it makes multiple calls to getDetailedWeather.

References

For a list of valid Weather Stations, try this format http://www.wunderground.com/weatherstation/ListStations.asp?selectedCountry=United+States and replace with your country of interest