Instalar paquetes y llamar librerias

#install.packages("riem")
library(riem)
library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
## ✔ ggplot2 3.3.6     ✔ purrr   0.3.4
## ✔ tibble  3.1.8     ✔ dplyr   1.0.9
## ✔ tidyr   1.2.0     ✔ stringr 1.4.0
## ✔ readr   2.1.2     ✔ forcats 0.5.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
library(lubridate)
## 
## Attaching package: 'lubridate'
## 
## The following objects are masked from 'package:base':
## 
##     date, intersect, setdiff, union
library(ggplot2)
#install.packages("plotly")
library(plotly)
## 
## Attaching package: 'plotly'
## 
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## 
## The following object is masked from 'package:stats':
## 
##     filter
## 
## The following object is masked from 'package:graphics':
## 
##     layout

Paso 1. Buscar la red (pais) ejemplo: Mexico, y copiar codigo

view(riem_networks())

Paso 2. Buscar la estacion (ciudad) ejemplo: Monterrey

view(riem_stations("MX__ASOS"))

Escribir ID: MMMY

Paso 3. Obtener datos del clima

monterrey<- riem_measures("MMMY")
str(monterrey)
## tibble [77,884 × 32] (S3: tbl_df/tbl/data.frame)
##  $ station          : chr [1:77884] "MMMY" "MMMY" "MMMY" "MMMY" ...
##  $ valid            : POSIXct[1:77884], format: "2014-01-01 00:16:00" "2014-01-01 00:49:00" ...
##  $ lon              : num [1:77884] -100 -100 -100 -100 -100 ...
##  $ lat              : num [1:77884] 25.8 25.8 25.8 25.8 25.8 ...
##  $ tmpf             : num [1:77884] 48.2 48.2 48.2 46.4 46.4 46.4 46.4 46.4 46.4 46.4 ...
##  $ dwpf             : num [1:77884] 46.4 46.4 46.4 46.4 46.4 44.6 44.6 44.6 44.6 44.6 ...
##  $ relh             : num [1:77884] 93.5 93.5 93.5 100 100 ...
##  $ drct             : num [1:77884] 0 120 120 120 110 100 110 130 60 0 ...
##  $ sknt             : num [1:77884] 0 3 5 6 5 5 4 3 3 0 ...
##  $ p01i             : num [1:77884] 0 0 0 0 0 0 0 0 0 0 ...
##  $ alti             : num [1:77884] 30.3 30.3 30.3 30.3 30.3 ...
##  $ mslp             : num [1:77884] NA NA NA NA NA ...
##  $ vsby             : num [1:77884] 4 3 1 0.25 0.12 0.12 0.06 0.06 0.06 0.12 ...
##  $ gust             : num [1:77884] NA NA NA NA NA NA NA NA NA NA ...
##  $ skyc1            : chr [1:77884] "SCT" "SCT" "SCT" "VV " ...
##  $ skyc2            : chr [1:77884] "BKN" "BKN" "BKN" NA ...
##  $ skyc3            : chr [1:77884] "OVC" "OVC" "OVC" NA ...
##  $ skyc4            : chr [1:77884] NA NA NA NA ...
##  $ skyl1            : num [1:77884] 700 300 200 200 100 100 100 100 100 100 ...
##  $ skyl2            : num [1:77884] 1200 400 300 NA NA NA NA NA NA NA ...
##  $ skyl3            : num [1:77884] 4000 900 500 NA NA NA NA NA NA NA ...
##  $ skyl4            : num [1:77884] NA NA NA NA NA NA NA NA NA NA ...
##  $ wxcodes          : chr [1:77884] NA "BR" "BR" "FG" ...
##  $ ice_accretion_1hr: logi [1:77884] NA NA NA NA NA NA ...
##  $ ice_accretion_3hr: logi [1:77884] NA NA NA NA NA NA ...
##  $ ice_accretion_6hr: logi [1:77884] NA NA NA NA NA NA ...
##  $ peak_wind_gust   : logi [1:77884] NA NA NA NA NA NA ...
##  $ peak_wind_drct   : logi [1:77884] NA NA NA NA NA NA ...
##  $ peak_wind_time   : logi [1:77884] NA NA NA NA NA NA ...
##  $ feel             : num [1:77884] 48.2 47.2 45.6 42.9 43.5 ...
##  $ metar            : chr [1:77884] "MMMY 010016Z 00000KT 4SM SCT007 BKN012 OVC040 09/08 A3028 RMK 8/5// BR" "MMMY 010049Z 12003KT 3SM BR SCT003 BKN004 OVC009 09/08 A3028 RMK 8/5// -DZ OCNL" "MMMY 010116Z 12005KT 1SM BR SCT002 BKN003 OVC005 09/08 A3028 RMK 8/6// -DZ OCNL" "MMMY 010120Z 12006KT 1/4SM FG VV002 08/08 A3029 RMK 8//// BC FG MOV SE/NW" ...
##  $ snowdepth        : logi [1:77884] NA NA NA NA NA NA ...

Paso 4. Extraer informacion requerida

este_mes<- subset(monterrey, valid >= as.POSIXct('2022-09-01 00:00') & valid <= as.POSIXct('2022-09-13 23:59'))

Graficas

plot(este_mes$valid,este_mes$relh)

Conclusion

Con este codigo nos es posible encontrar datos sobre el clima de cualquier ciudad que cuente con un sistema ASOS los cuales normalmente se encuentran en los aeropuertos. En este ejemplo buscamos los datos del clima de la ciudad de monterrey en el ultimo mes. El clima afecta a muchos negocios y es util saber los pronosticos y el clima de los ultimos dias.