Created
December 1, 2016 03:26
-
-
Save Ray901/79e3c1c53928c991c06d310e6908728b to your computer and use it in GitHub Desktop.
get weather data by darksky api
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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