Skip to contents

Introduction

We can list down all available locations using available_locations:

And simply fetch the weather data of a location using get_weather:

mumbai <- available_locations() %>%
    dplyr::filter(cityName == "Mumbai")
DT::datatable(data = mumbai)
api_key <- Sys.getenv("ZOMATO_API_KEY")
DT::datatable(data = get_weather(api_key = api_key, latitude = mumbai$latitude[1], longitude = mumbai$longitude[1]))

Get all locations at once:

result <- apply(mumbai, 1, function(row) get_weather(api_key = api_key, latitude = row[4], longitude = row[5]))
result.combined <- dplyr::bind_rows(result)
result.joined <- cbind(mumbai, result.combined %>%
    dplyr::select(-device_type, -latitude, -longitude))
DT::datatable(data = result.joined %>%
    dplyr::arrange(desc(temperature)))
Session Info
## R version 4.4.0 (2024-04-24)
## Platform: aarch64-apple-darwin23.4.0
## Running under: macOS Sonoma 14.4.1
## 
## Matrix products: default
## BLAS:   /opt/homebrew/Cellar/openblas/0.3.27/lib/libopenblasp-r0.3.27.dylib 
## LAPACK: /opt/homebrew/Cellar/r/4.4.0_1/lib/R/lib/libRlapack.dylib;  LAPACK version 3.12.0
## 
## locale:
## [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
## 
## time zone: Asia/Kolkata
## tzcode source: internal
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
## [1] weatherunion_0.1.0.9001 magrittr_2.0.3         
## 
## loaded via a namespace (and not attached):
##  [1] jsonlite_1.8.8    dplyr_1.1.4       compiler_4.4.0    tidyselect_1.2.1 
##  [5] jquerylib_0.1.4   systemfonts_1.0.6 textshaping_0.3.7 yaml_2.3.8       
##  [9] fastmap_1.1.1     R6_2.5.1          generics_0.1.3    curl_5.2.1       
## [13] httr2_1.0.1       knitr_1.46        htmlwidgets_1.6.4 tibble_3.2.1     
## [17] desc_1.4.3        bslib_0.7.0       pillar_1.9.0      rlang_1.1.3      
## [21] utf8_1.2.4        DT_0.33           cachem_1.0.8      xfun_0.43        
## [25] fs_1.6.4          sass_0.4.9        memoise_2.0.1     cli_3.6.2        
## [29] withr_3.0.0       pkgdown_2.0.9     formatR_1.14      crosstalk_1.2.1  
## [33] digest_0.6.35     rstudioapi_0.16.0 rappdirs_0.3.3    lifecycle_1.0.4  
## [37] vctrs_0.6.5       evaluate_0.23     glue_1.7.0        ragg_1.3.0       
## [41] fansi_1.0.6       rmarkdown_2.26    purrr_1.0.2       tools_4.4.0      
## [45] pkgconfig_2.0.3   htmltools_0.5.8.1