Skip to content

Commit 535d51f

Browse files
committed
Fix merge conflicts
2 parents 62a382f + 71be0cc commit 535d51f

File tree

2 files changed

+81
-0
lines changed

2 files changed

+81
-0
lines changed

docs/data/current-rio_group.rds

792 Bytes
Binary file not shown.

docs/index.rmd

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
---
2+
title: "owmr - An R Interface to OpenWeatherMap"
3+
output:
4+
html_document:
5+
theme: united
6+
7+
---
8+
9+
```{r setup, include=FALSE}
10+
knitr::opts_chunk$set(echo = TRUE)
11+
library(magrittr)
12+
source("../tmp/settings.R")
13+
```
14+
15+
## Introduction
16+
17+
```{r introduction}
18+
library(owmr)
19+
20+
owm_cities %>% head()
21+
22+
ls("package:owmr") %>% data.frame(obj = .)
23+
```
24+
25+
## Installation
26+
27+
```{r installation, eval=F}
28+
# stable
29+
install.packages("owmr")
30+
31+
# unstable
32+
require("devtools")
33+
34+
devtools::install_github("crazycapivara/owmr/")
35+
```
36+
37+
## Quick start
38+
39+
```{r quick-start}
40+
# Set up API key
41+
owmr_settings(api_key)
42+
43+
# Get latitude and longitude for Rio de Janeiro
44+
rio <- search_city_list("Rio de Janeiro")
45+
rio %>% as.list()
46+
47+
# Fetch current weather data for some cities around Rio de Janeiro
48+
owm_data <- find_cities_by_geo_point(
49+
lat = rio$lat,
50+
lon = rio$lon,
51+
cnt = 9,
52+
units = "metric")$list %>% tidy_up_()
53+
54+
owm_data %>% names()
55+
56+
# Round temperature values
57+
owm_data <- parse_columns(owm_data, list(temp = round))
58+
59+
# Create popup template to show up on leaflet map
60+
popup_tpl <- paste0(
61+
"<b>{{name}}</b></br>",
62+
"{{coord_lon}}, {{coord_lat}}</br>",
63+
"{{temp}}°C, ",
64+
"<i>{{weather_description}}</i>"
65+
)
66+
67+
# Test it ...
68+
popup_tpl %$$% owm_data %>% head(2)
69+
70+
# Load leaflet
71+
require("leaflet")
72+
73+
# Create leaflet map and add weather data to it
74+
leaflet(width = "100%") %>%
75+
addProviderTiles("CartoDB.DarkMatter") %>%
76+
add_weather(owm_data, icon = owm_data$weather_icon, template = popup_tpl)
77+
78+
## Click on icons to get further information ##
79+
80+
## ... ##
81+
```

0 commit comments

Comments
 (0)