This package provides four useful wrapper functions around the OpenWeatherMap API. The four functions are: distmap()
, cloudmap()
, get_weather()
, get_weather_four_days()
and cwd()
.
distmap(api, 'city1', 'city2')
: Calculate distance between two cities
Argument:
api
- User's API
city1
- Name of a city (lowercase)
city2
- Name of a city (lowercase)
*Value:*
Returns a string telling the user the distance between two cities in km
cloudmap(api, 'alberta', dense = 0.2 )
: Returns most popular response on webpage. Arguments:
`api` - User's API
`city` - Name of a city (lowercase)
`dense` - Transparency of points
Value:
Returns a response. This will be of a character type.
get_weather_four_days(api, 'Vancouver' )
: Returns 4-day weather forecast for selected city
Arguments:
api
- API Key for openweathermap.org
city
- City name and country code divided by comma, use ISO 3166 country codes
Value:
Data frame containing temp_min, temp_max, humidity and weather for the next 4 days in city local time. Temperature in Celsius
cwd(api, 'Vancouver' )
: Get current weather description
Arguments:
api
- API Key for openweathermap.org
location
- A string, the location where you want to check the weather
Value:
A string that describe current weather in the location indicated
Install this package directly from GitHub:
devtools::install_github("UBC-MDS/weatheR")
Simple example demonstrating the functionality of this package:
# load package
library(weatheR)
api <- "&APPID=8196eccade1594d99afd30e0924dca7d"
# Calculate distance between two cities
distmap(api, 'vancouver', 'toronto')
# Returns a plot showing how dense clouds are in the area
cloudmap(api, 'alberta', dense = 0.2 )
# Returns weather forecast for the next 24 hours for selected city
get_weather(api, city):
# Returns 4-day weather forecast for selected city
get_weather_four_days(api, 'Vancouver')
# Get current weather description
cwd(api,"Vancouver,CA")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.