knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

weatherapi

xintian927

The goal of weatherapi is to wrap the weather api accessible through weatherapi.com. This API enables us to get current and historical weather information, astronomical information, local time-zone information, and sports events information.

Available functions:

Installation

You can install the development version of weatherapi from GitHub with:

devtools::install_github("xintian927/534-project")

Setup

This package relies on the API key provided by the Weather API. To get started on using this package, please follow these steps:

  1. Sign-up for an account here: https://www.weatherapi.com/signup.aspx
  2. Go to your "my account" page and copy your API key
  3. Open RStudio and set your API key in the .Renviron file
  4. You can do this by running the following code in your R console
    usethis::edit_r_environ()
  5. Then add this line inside the .Renviron file
    API_KEY = <your_api_key>
  6. Save and close the .Renviron file and you are good to go!

Example

This is an example which shows you how to get the current weather information:

library(weatherapi)
get_current_weather("Kelowna")

You can also generate plots, for example:

library(ggplot2)
library(reshape2)

# Get current weather data
loc <- c("London", "New York", "Paris", "Melbourne", "Singapore") 
data <- get_current_weather(loc,"no")

# Get temperature info and melt dataframe
data <- data[c("location.name", "current.temp_c", "current.feelslike_c")]
data <- melt(data)

# Plot temperature
ggplot(data=data, aes(x=location.name, y=value, group=variable, linetype=variable)) +
  geom_line()+
  geom_point()+
  labs(title="Temperature by Location", subtitle="(in celcius)", x="", y="", linetype="")

Getting help

If you encounter a clear bug, you can email us at:
- evelynsugihermanto@yahoo.com
- lianqi20209@gmail.com
- tjyh111@163.com
- veeramanival@gmail.com


Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.



evelynsugi/weatherapi documentation built on April 7, 2022, 12:43 p.m.