- Fang Yang (@fyang95)
- Susan Fung (@susan-fung)
- Ted Thompson (@TeddTech)
- Tina Qian (@TinaQian2017)
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 citiesArgument:
api- User's APIcity1- 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 APIcity- Name of a city (lowercase)dense- Transparency of pointsValue:
Returns a response. This will be of a character type.
-
get_weather_four_days(api, 'Vancouver' ): Returns 4-day weather forecast for selected cityArguments:
api- API Key for openweathermap.orgcity- City name and country code divided by comma, use ISO 3166 country codesValue:
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 descriptionArguments:
api- API Key for openweathermap.orglocation- A string, the location where you want to check the weatherValue:
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")