Learn R Programming

Rforecastio (version 2.0.0)

get_current_forecast: Retrieve the current forecast (for the next week)

Description

The Forecast API lets you query for most locations on the globe, and returns:
  1. current conditions
  2. minute-by-minute forecasts out to 1 hour (where available)
  3. hour-by-hour forecasts out to 48 hours
  4. day-by-day forecasts out to 7 days

Usage

get_current_forecast(latitude, longitude, units = "us", language = "en", exclude = NULL, extend = NULL)

Arguments

latitude
forecast latitude (character, decimal format)
longitude
forecast longitude (character, decimal format)
units
return the API response in units other than the default Imperial unit
language
return text summaries in the desired language
exclude
exclude some number of data blocks from the API response. This is useful for reducing latency and saving cache space. This should be a comma-separated string (without spaces) including one or more of the following: (currently, minutely, hourly, daily, alerts, flags). Crafting a request with all of the above blocks excluded is exceedingly silly and not recommended. Setting this parameter to NULL (the default) does not exclude any parameters from the results.
extend
setting this parameter to hourly the API will return hourly data for the next seven days, rather than the next two.

Value

an rforecastio object that contains the original JSON response object, a list of named `tbl_df` `data.frame` objects corresponding to what was returned by the API and relevant response headers (cache-control, expires, x-forecast-api-calls, x-response-time).

Details

If you wish to have results in something besides Imperial units, set units to one of (si, ca, uk). Setting units to auto will have the API select the relevant units automatically, based on geographic location. This value is set to us (Imperial) units by default.

If you wish to have text summaries presented in a different language, set language to one of (ar, bs, de, es, fr, it, nl, pl, pt, ru, sv, tet, tr, x-pig-latin, zh). This value is set to en (English) by default.

See the Options section of the official Forecast API documentation for more information.

Examples

Run this code
tmp <- get_current_forecast(37.8267, -122.423)

Run the code above in your browser using DataLab