knitr::opts_chunk$set(eval = FALSE)
Read the provided documents/books about how to work with the project, and did some research on the APIs that can be used for the project.
Provided an option for the group to choose.
The github repo hasn't been set up yet.
base_url <- "http://api.weatherapi.com/v1/history.json?" full_url <- POST(base_url, query = list(key=key,q=q,dt=dt),encode = "raw") path<-paste0("key=",key,"&q=",q,"&dt=",dt) resp <- GET(full_url)
if (http_type(resp) != "application/json") { stop("API did not return json", call. = FALSE) }
parsed <- jsonlite::fromJSON(content(resp, as = "text", encoding = "UTF-8"), simplifyVector = FALSE)
if (http_error(resp)) { stop( sprintf( "GitHub API request failed [%s]\n%s\n<%s>", status_code(resp), parsed$error$message, parsed$error$code ), call. = FALSE ) }
structure( list( location_data= parsed[[1]], daily_data = parsed[[2]]$forecastday[[1]]$day, astro_data= parsed[[2]]$forecastday[[1]]$astro, hourly_data=parsed[[2]]$forecastday[[1]]$hour, path = path, response = resp, class = "weather_api_history" ) )
res<-weather_api_history("##samplekeyhere##","London","2022-02-08") #(1)data #location data res$location_data #daily temp summary res$daily_data #astro data res$astro_data #hourly data length(res$hourly_data)#a list res$hourly_data[[1]] #(2)information #path res$path #response res$response #class res$class
The "history" part is one out of the 3 critical parts we are going to query.
https://github.com/xintian927/534-proejct/commit/5f0d6356411705a902f02411c9bbf6824816dfb9
https://github.com/xintian927/534-proejct/commit/8d08fa754f9843ed8563728ea55b8ee561073d88
https://github.com/xintian927/534-proejct/commit/af2e22367c9a9bec55b47d69ed4a413142d340f2
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.