weatherData (version 0.5.0)

getWeatherForMultipleYears: For Multiple Years, fetch the weather data for a station

Description

Function will return a data frame with all the records for a given station_id for all the years requested. If the current year is supplied, it will return records until the current Sys.Date() ("today"). 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

getWeatherForMultipleYears(station_id, start_year, end_year,
  station_type = "airportCode", opt_detailed = FALSE,
  opt_write_to_file = FALSE)

Arguments

station_id

is 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. You can get station_id's for a given location by calling getStationCode()

start_year

is a valid year in the past (numeric, YYYY format)

end_year

is a valid year in the past (numeric, YYYY format)

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

Value

A data frame with each row containing:

  • Date and Time stamp (for each date specified)

  • Temperature and/or other weather columns sought

Details

Note that this function is a light wrapper for getWeatherForYear

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

Examples

Run this code

dat <- getWeatherForMultipleYears("SFO", 2013, 2017)

# If opt_detailed is turned on, you will get a large data frame
wx_SF <- getWeatherForMultipleYears("SIN", 2014, 2017, opt_detailed=TRUE)

Run the code above in your browser using DataCamp Workspace