Skip to content

Instantly share code, notes, and snippets.

@Ray901
Created December 1, 2016 03:26
Show Gist options
  • Save Ray901/79e3c1c53928c991c06d310e6908728b to your computer and use it in GitHub Desktop.
Save Ray901/79e3c1c53928c991c06d310e6908728b to your computer and use it in GitHub Desktop.
get weather data by darksky api
rm(list=ls())
library(darksky)
library(data.table)
library(dplyr)
darksky_api_key()
setStart <- "2016-11-27"
setEnd <- "2016-11-30"
setDate <- paste0(seq.Date(as.Date(setStart),as.Date(setEnd),by = "day"),"T12:00:00-04:00")
weatherList <- lapply(
setDate,function(x) {
get_forecast_for(25.050144, 121.510296,units = "ca", x)
}
)
weatherDat <- rbindlist(
lapply(weatherList,function(x) {
result <- x$hourly %>%
dplyr::select(time,summary,precipType,temperature,windSpeed,cloudCover,pressure)
return(result)
})
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment