diff --git a/.Rbuildignore b/.Rbuildignore index 994f0c0..0da8b04 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -1,3 +1,6 @@ +^pkgdown$ +^_pkgdown\.yml$ +^docs$ ^.*\.Rproj$ ^\.Rproj\.user$ ^\.travis\.yml$ @@ -9,5 +12,4 @@ ^cran-comments\.md$ ^codemeta\.json$ -^docs$ ^docs/$ diff --git a/.gitignore b/.gitignore index c833a2c..6deefea 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +docs/ .Rproj.user .Rhistory .RData diff --git a/.travis.yml b/.travis.yml index a3e0105..f1da6f2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,10 +2,17 @@ language: r -r: - - oldrel - - release - - devel +matrix: + include: + - r: release + before_cache: Rscript -e 'remotes::install_cran("pkgdown")' + deploy: + provider: script + script: Rscript -e 'pkgdown::deploy_site_github()' + skip_cleanup: true + - r: devel + - r: oldrel + sudo: false cache: packages diff --git a/_pkgdown.yml b/_pkgdown.yml new file mode 100644 index 0000000..f3ce14d --- /dev/null +++ b/_pkgdown.yml @@ -0,0 +1,9 @@ +destination: docs + +authors: + rOpenSci: + href: "https://ropensci.org" + html: "" + + Maëlle Salmon: + href: "https://masalmon.eu" diff --git a/docs/CONDUCT.html b/docs/CONDUCT.html deleted file mode 100644 index df056e1..0000000 --- a/docs/CONDUCT.html +++ /dev/null @@ -1,140 +0,0 @@ - - - -
- - - - -As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
-We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
-Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
-Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
-Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
-This Code of Conduct is adapted from the Contributor Covenant (http:contributor-covenant.org), version 1.0.0, available at http://contributor-covenant.org/version/1/0/0/
-vignettes/forecast.Rmd
-
- For Christmas I’ll travel to Marseille. What temperatures should I expect there? I could of course open a weather app, but in this vignette I want to give an example using the riem
and forecast
packages.
The name of the network for France is “FR__ASOS“. I already know there’s only one airport near the city.
-library("riem")
-library("dplyr")
-france_airports <- riem_stations(network = "FR__ASOS")
-marseilles_airport <- filter(france_airports, grepl("MARSEILLE", name))
-marseilles_airport
## # A tibble: 1 x 4
-## id name lon lat
-## <chr> <chr> <dbl> <dbl>
-## 1 LFML MARSEILLE/MARIGN 5.23 43.4
-We’ll transform it to daily average, and convert Fahrenheit to Celsius thanks to the weathermetrics
package. We impute the missing values and remove outliers via the use of forecast::tsclean
.
marseille <- riem_measures(station = marseilles_airport$id,
- date_start = "2010 01 01")
-
-marseille <- group_by(marseille, day = as.Date(valid))
-marseille <- summarize(marseille, temperature = mean(tmpf))
-marseille <- mutate(marseille, temperature = weathermetrics::fahrenheit.to.celsius(temperature))
-library("ggplot2")
-
-
-library("forecast")
-marseille_ts = ts(as.vector(tsclean(marseille$temperature)), freq=365.25, start=c(2010, 1))
-autoplot(marseille_ts) +
- ylab("Daily average temperature in Marseille airport (ºC)") +
- xlab("Time (days)")
For this we use the forecast
package. We use the stlm
because our time series obviously present yearly seasonality.
fit <- stlm(marseille_ts)
-pred <- forecast(fit, h = 7)
-# plot
-theme_set(theme_gray(base_size = 14))
-autoplot(pred) +
- ylab("Daily average temperature in Marseille airport (ºC)") +
- xlab("Time (days)") +
- ggtitle("How cold will I be during the holidays?",
- subtitle = "Data accessed via the rOpenSci riem package and forecasted with forecast")
Mmh I don’t see anything, but autoplot.forecast
has an include
parameters, so I’ll only plot the last 31 values.
Ok, what if I had travelled to, say, Hyderabad in India?
- -Without surprise, we forecast I’d have enjoyed warmer weather.
-I wouldn’t advise you to really use such code to forecast temperature, but I’d recommend you to use riem
for getting weather airport data quite easily and to dig more deeply into forecast
functionalities if you’re interested in time series forecasting. And stay warm!
This package allows to get weather data from ASOS stations (airports) via the awesome website of the Iowa Environment Mesonet.
-Install the package with:
- -Or install the development version using devtools with:
- -library("riem")
-riem_networks()
-#> # A tibble: 267 x 2
-#> code name
-#> <chr> <chr>
-#> 1 AE__ASOS United Arab Emirates ASOS
-#> 2 AF__ASOS Afghanistan ASOS
-#> 3 AG__ASOS Antigua and Barbuda ASOS
-#> 4 AI__ASOS Anguilla ASOS
-#> 5 AK_ASOS Alaska ASOS
-#> 6 AL_ASOS Alabama ASOS
-#> 7 AL__ASOS Albania ASOS
-#> 8 AM__ASOS Armenia ASOS
-#> 9 AN__ASOS Netherlands Antilles ASOS
-#> 10 AO__ASOS Angola ASOS
-#> # ... with 257 more rows
riem_stations(network = "IN__ASOS")
-#> # A tibble: 122 x 4
-#> id name lon lat
-#> <chr> <chr> <dbl> <dbl>
-#> 1 VEAT "AGARTALA " 91.2 23.9
-#> 2 VOAT Agatti 72.2 10.8
-#> 3 VIAG "AGRA (IN-AFB) " 78.0 27.2
-#> 4 VAAH "AHMADABAD " 72.6 23.1
-#> 5 VAAK "AKOLA AIRPORT " 77.1 20.7
-#> 6 VIAH "ALIGARH " 78.1 27.9
-#> 7 VIAL ALLAHABAD (IN-AF 81.7 25.4
-#> 8 VIAR "AMRITSAR " 74.9 31.6
-#> 9 VAOR Arkonam 79.7 13.1
-#> 10 VOAR Arkonam 79.7 13.1
-#> # ... with 112 more rows
Possible variables are (copied from here, see also the ASOS user guide)
-station: three or four character site identifier
valid: timestamp of the observation (UTC)
tmpf: Air Temperature in Fahrenheit, typically @ 2 meters
dwpf: Dew Point Temperature in Fahrenheit, typically @ 2 meters
relh: Relative Humidity in %
drct: Wind Direction in degrees from north
sknt: Wind Speed in knots
p01i: One hour precipitation for the period from the observation time to the time of the previous hourly precipitation reset. This varies slightly by site. Values are in inches. This value may or may not contain frozen precipitation melted by some device on the sensor or estimated by some other means. Unfortunately, we do not know of an authoritative database denoting which station has which sensor.
alti: Pressure altimeter in inches
mslp: Sea Level Pressure in millibar
vsby: Visibility in miles
gust: Wind Gust in knots
skyc1: Sky Level 1 Coverage
skyc2: Sky Level 2 Coverage
skyc3: Sky Level 3 Coverage
skyc4: Sky Level 4 Coverage
skyl1: Sky Level 1 Altitude in feet
skyl2: Sky Level 2 Altitude in feet
skyl3: Sky Level 3 Altitude in feet
skyl4: Sky Level 4 Altitude in feet
presentwx: Present Weather Codes (space seperated), see e.g. this manual for further explanations.
metar: unprocessed reported observation in METAR format
measures <- riem_measures(station = "VOHY", date_start = "2000-01-01", date_end = "2016-04-22")
-head(measures)
-#> # A tibble: 6 x 24
-#> station valid lon lat tmpf dwpf relh drct sknt
-#> <chr> <dttm> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
-#> 1 VOHY 2000-01-01 00:00:00 78.5 17.5 61.5 57.4 86.3 0. 0.
-#> 2 VOHY 2000-01-01 01:40:00 78.5 17.5 64.4 60.8 88.1 0. 0.
-#> 3 VOHY 2000-01-01 02:40:00 78.5 17.5 69.8 60.8 73.1 140. 5.
-#> 4 VOHY 2000-01-01 03:00:00 78.5 17.5 68.0 61.7 80.3 140. 4.
-#> 5 VOHY 2000-01-01 03:40:00 78.5 17.5 71.6 62.6 73.3 140. 5.
-#> 6 VOHY 2000-01-01 05:40:00 78.5 17.5 75.2 55.4 50.2 90. 6.
-#> # ... with 15 more variables: p01i <dbl>, alti <dbl>, mslp <dbl>,
-#> # vsby <dbl>, gust <dbl>, skyc1 <chr>, skyc2 <chr>, skyc3 <chr>,
-#> # skyc4 <chr>, skyl1 <dbl>, skyl2 <dbl>, skyl3 <dbl>, skyl4 <dbl>,
-#> # wxcodes <chr>, metar <chr>
For conversion of wind speed or temperature into other units, see this package.
-This package allows to get weather data from ASOS stations (airports) via the awesome website of the Iowa Environment Mesonet.
-Install the package with:
- -Or install the development version using devtools with:
- -Please refer to the pkgdown
website to read docs, in particular the reference and the vignettes.
Submit your use cases by opening a new issue!
-@Ryo-N7’s Where to live in Japan: XKCD-themed climate plots and maps!
In a course: @byuidatascience’s M335 Task 15: How is the weather?
ropenaq
in R doing citation(package = 'riem')
-NEWS.md
- R/measures.R
- Function for getting weather data from one station
- - -riem_measures(station = "VOHY", date_start = "2014-01-01", - date_end = as.character(Sys.Date()))- -
station | -station ID, see riem_stations() |
-
---|---|
date_start | -date of start of the desired data, e.g. "2000-01-01" |
-
date_end | -date of end of the desired data, e.g. "2016-04-22" |
-
a data.frame (tibble tibble) with measures, the number of columns can vary from station to station, -but possible variables are
station: three or four character site identifier
valid: timestamp of the observation (UTC)
tmpf: Air Temperature in Fahrenheit, typically @ 2 meters
dwpf: Dew Point Temperature in Fahrenheit, typically @ 2 meters
relh: Relative Humidity in
drct: Wind Direction in degrees from north
sknt: Wind Speed in knots
p01i: One hour precipitation for the period from the observation time to the time of the previous hourly precipitation reset. This varies slightly by site. Values are in inches. This value may or may not contain frozen precipitation melted by some device on the sensor or estimated by some other means. Unfortunately, we do not know of an authoritative database denoting which station has which sensor.
alti: Pressure altimeter in inches
mslp: Sea Level Pressure in millibar
vsby: Visibility in miles
gust: Wind Gust in knots
skyc1: Sky Level 1 Coverage
skyc2: Sky Level 2 Coverage
skyc3: Sky Level 3 Coverage
skyc4: Sky Level 4 Coverage
skyl1: Sky Level 1 Altitude in feet
skyl2: Sky Level 2 Altitude in feet
skyl3: Sky Level 3 Altitude in feet
skyl4: Sky Level 4 Altitude in feet
presentwx: Present Weather Codes (space seperated), - see e.g. [this manual](http://www.ofcm.gov/fmh-1/pdf/H-CH8.pdf) for further explanations.
metar: unprocessed reported observation in METAR format
The data is queried through https://mesonet.agron.iastate.edu/request/download.phtml.
- - -# NOT RUN { -riem_measures(station = "VOHY", date_start = "2000-01-01", date_end = "2016-04-22") -# }-
R/networks.R
- Function for getting ASOS and AWOS networks
- - -riem_networks()
-
- a data.frame (tibble tibble) with the names and codes of available networks.
- - -# NOT RUN { -riem_networks() -# }-
R/stations.R
- Function for getting stations of an ASOS network
- - -riem_stations(network = NULL)- -
network | -A single network code, see riem_networks() for finding the code corresponding to a name. |
-
---|
a data.frame (tibble tibble) with the id, name, longitude (lon) and latitude (lat) of each station in the network.
- -You can see a map of stations in a network at https://mesonet.agron.iastate.edu/request/download.phtml.
- - -# NOT RUN { -riem_stations(network = "IN__ASOS") -# }-